JavaScript data types
Maya Ifrim

Maya Ifrim

Mar 24, 2023

JavaScript data types

JavaScript types can be categorized into three main categories:

1. primitives

2. structural types

3. structural root primitives

1. Primitives are basic data types that represent a single value. There are six primitive types in JavaScript: boolean, number, string, BigInt, symbol and undefined.

Boolean type represents a boolean value of either true or false.


Number type represents a numeric value, including integers and floating-point numbers.


String. This type represents a sequence of characters, enclosed in single or double quotes.


BigInt type represents an integer value of arbitrary length, larger than the range of the Number type.


In the example above, we declare two BigInt variables 'bigNumber' and 'anotherBigNumber'. We can create a BigInt by appending n to the end of an integer literal, or by calling the BigInt() function with a string argument.

Symbol. This type represents a unique and immutable value that can be used as an identifier for object properties.


Undefined type represents a value that is not assigned to a variable or property.


2. Structural types are complex types that represent a collection of data or a set of behaviors. There are two structural data types: Object and Function.

Object type represents a collection of key-value pairs, where the values can be of any type, including other objects and functions.


Function. This type represents a reusable block of code that can be called with arguments and can return a value.


3. Structural root primitives are special types that are part of the language's object system but behave like primitives.

Null is a structural root primitive type which represents a deliberate non-value, usually indicating the absence of an object or value. It is considered a structural root primitive because it is of type "object" but has a special behavior.


While null is considered a structural root primitive type because it is of type 'object' but has a special behavior, undefined is not a structural root primitive type because it is not an instance of any constructor function and does not have any properties or methods associated with it.

Maya Ifrim

Maya Ifrim

Passionate React developer with a love for crafting beautiful and user-friendly interfaces.

Leave a comment

Related Posts