Skip to main content

JavaScript Data Types (Primitive Data Types and Complex Data Types)

 

Ziggy Rafiq blog post on JavaScript Data Types (Primitive Data Types and Complex Data Types)



JavaScript Data Types (Primitive Data Types and Complex Data Types)


JavaScript is a dynamically typed language, which means that variables do not have a fixed type. Instead, their type is determined at runtime based on the value assigned to them. JavaScript has several built-in data types that can be used to represent different types of values, including primitive data types and complex data types.

Primitive data types in JavaScript include number, string, boolean, null, undefined, and symbol. The number represents both integer and floating-point numbers. The string represents textual data. Boolean represents a logical entity and can have two values: true or false. Null represents a deliberate non-value, and undefined represents an unintentional absence of any value. The symbol represents a unique identifier value.

Complex data types in JavaScript include objects and functions. An object is a collection of properties, where each property has a name and a value. Properties can be accessed using dot notation or bracket notation. A function is a type of object that can be called a subroutine to perform a specific task. Functions can be defined using the function keyword and can have parameters and return values.

In addition to these data types, JavaScript also has several built-in operators that can be used to perform various operations on values. These operators include arithmetic operators, assignment operators, comparison operators, logical operators, conditional (ternary) operators, and bitwise operators. Understanding these data types and operators is crucial for developing effective and efficient JavaScript code.

Primitive Data Types

Number: represents both integer and floating-point numbers.

Ziggy Rafiq blog post on Primitive Data Types code example of number

String: represents textual data.

JavaScript Primitive Data Types example of string in Ziggy Rafiq Blog Post




Boolean: represents a logical entity and can have two values: true or false.

Ziggy blog post on JavaScript Primitive Data Types  Boolean code example



Null: represents a deliberate non-value and has a special keyword null and Undefined: represents an unintentional absence of any value and has a special keyword undefined.

JavaScript code example on Primitive Data Types  undefined and null by Ziggy Rafiq




Symbol: represents a unique identifier value.

Ziggy Rafiq blog post on JavaScript Primitive Data Types Symbol code example




Complex Data Types

Object: represents a collection of properties, where each property has a name and a value.

JavaScript Complex Data Types Code example by Ziggy Rafiq using Object







Function: a type of object that can be called a subroutine to perform a specific task.

JavaScript Complex Data Types code example of Function by Ziggy Rafiq



Remember that JavaScript is a dynamically typed language, which means that the type of a variable is determined at runtime, and can change during the program's execution.

Comments

Most Viewed Ziggy Rafiq Blog Posts

How to use Enum Data Values with .Net 6.0 Framework and Entity Framework Core 6

How to use Enum Data Values with .Net 6.0 Framework and Entity Framework Core 6 Overview An Enum (Enumeration) is a group of constants that are read-only value types. By default, the first value of the Enum variable is 0 i.e. Here we will create an Enum of Priorities type with read-only values of Highest, Normal and Low. We will set the read-only values using an integer assigning a number next to the value. By default, the integer value will start with 0. Here we will be assigning the integer value next to the Enum value such as in the below example and we will use a comma (,) to separate the item in the list of Enum(Enumeration).  We create Enum by using the Enum keyword and then using class, interface, and abstract. The reason we use an Enum is to ensure we improve our application performance and improve application readability, and maintainability, and reduces the complexity of the application hence why if you take a look at the example below of Status (NotStarted, Started, Complete

A Complete Guide to Using GUIDs in C# with Code Examples

  Overview In this post, we are looking at GUIDs (Globally Unique Identifiers), which are widely used in C# for generating unique identifiers for objects, entities, and resources in a system. In this post, we'll explore the basics of GUIDs in C#, their advantages, and how to convert strings to GUIDs. In this post, we have used Guid Generator to create the GUID from the following URL Address https://guidgenerator.com/ What is GUID GUID (Globally Unique Identifier) in C# is a 128-bit value that is used to identify objects, entities, or resources in a unique manner across different systems and applications. It is also known as UUID (Universally Unique Identifier) in some other programming languages.   GUIDs are generated using a combination of unique factors such as the MAC address of the network adapter, the current time and date, and a random number. The resulting GUID is a string of 32 hexadecimal digits separated by hyphens, such as "b86f2096-237a-4059-8329-1bbcea72769b&

Primitives Data Types and None-Primitives Data Types in C# with Code Examples

  Overview I wrote this post to provide an explanation of primitive and non-primitive data types in C#. C# is a strongly typed programming language, where each variable and expression must have a specific data type. C# data types are categorized into two primary groups: primitive data types and non-primitive data types. Primitive data types are the simplest data types available in programming languages. They are typically pre-defined data types and can represent a single value, such as a boolean value, character, or integer. Examples of primitive data types include int, char, float, double, and boolean, which are common in programming languages like C++, C, and Java. Non-primitive data types are also referred to as composite data types or reference data types. They are constructed from primitive data types and are more complex than primitive data types. Non-primitive data types can hold multiple values and allow for the creation of more intricate data structures like tables, lists,