JS - Data Types

aigle-levant · September 8, 2024

JS has 2 kinds of data types. Let us check them out…

Data type

JS has 2 categories of data types : primitive and object.

Primitive

This is the collection of JS’ in-built data types. They can store only a single value of the specific data type.

String : Stores text values [called strings] that are assigned using quotes or template literals.

Number : Stores numeric values, be it integer or decimal.

Boolean : Returns either of its 2 values - true or false

BigInt : Stores large integers; is also created by appending n to end of an integer.

null : Stores only null as value

Undefined : Default value for any variable that’s been declared, but not initialized.

Symbol : An unique identifier value with optional description

Unlike other types, variables with null type can’t be tested for type using typeof operator. It simply returns object if you do so.

Object

It is a mutable data type representing anything that isn’t a primitive. This includes arrays, functions, objects, etc.