Skip to main content

Data Types in JavaScript

Explanation:

  • Immutable types: Their values cannot be changed after creation.
  • Mutable types: Their contents can be modified after creation (e.g., objects and arrays).
tip
  • Primitive types are the basic data types that are immutable and are stored by value. Each primitive type represents a single value.
  • Non-Primitive (Reference) types are more complex and are mutable. They can store collections of values or more complex entities. These types are stored by reference, meaning that variables refer to the memory address where the data is stored.
Data TypeImmutableStorage TypeDescription
NumberYesvalueinteger or floating-point numbers, including +Infinity, -Infinity, and NaN.
StringYesvaluetextual data enclosed in single, double, or backticks (template literals).
BooleanYesvaluelogical entity: true or false.
nullYesvaluean intentional absence of any object value.
undefinedYesvaluevariable that has been declared but not assigned a value.
BigIntYesvaluelarge integers with arbitrary precision (greater than the limit of Number).
SymbolYesvalueunique and immutable value, often used for object property keys.
ObjectYesreferencecollection of key-value pairs (e.g., objects, arrays, functions).
ArrayYesreferencetype of object used to store ordered collections of data (indexed by numbers).
FunctionYesreferenceblock of code designed to perform a specific task.