JavaScript Data Types

JavaScript Tutorial

JavaScript Data Types

JavaScript has two categories of data types:


1. Primitive Data Types

Primitive types are simple, immutable (cannot be changed), and stored directly in memory.

Data TypeExampleDescription
String"Hello"Text data
Number10, 10.5Numeric values (integer + float)
BigInt123nVery large numbers
Booleantrue / falseLogical values
Undefinedlet a;Variable declared but not assigned
Nulllet a = null;Empty or intentionally no value
SymbolSymbol("id")Unique and immutable value

Examples:



2. Non-Primitive (Reference) Types

These are objects and stored by reference.

TypeExample
Object{name:"John", age:30}
Array["apple", "banana"]
Functionfunction hello(){...}

Example:



📌 Type Checking Using typeof


⚠️ Note: typeof null returns "object" — this is a known JavaScript mistake from early versions.


🧠 Special Notes

  • Strings can use " ", ' ' or ` ` (template literals):


  • JavaScript Numbers are always floating-point:



🚀 Summary Table

CategoryData Types
PrimitiveString, Number, BigInt, Boolean, Undefined, Null, Symbol
Non-PrimitiveObject, Array, Function

You may also like...