JavaScript has 8 main data types, divided into primitive and non-primitive (reference) types.
1️⃣ Primitive Data Types
These are immutable and stored by value.
-
String – Represents textual data.
let name = "Teekam"; -
Number – Represents integers and floating-point numbers.
let age = 25; let price = 99.99; -
Boolean – Represents true or false.
let isLoggedIn = true; -
Undefined – A variable declared but not assigned a value.
let x; // undefined -
Null – Represents an intentional absence of value.
let empty = null; -
Symbol – Unique and immutable value, often used as object keys.
let id = Symbol("id"); -
BigInt – Used for integers larger than the safe number limit.
let bigNumber = 12345678901234567890n;
2️⃣ Non-Primitive (Reference) Data Type
Stored by reference (not by value).
-
Object – Used to store collections of data or complex entities.
let user = { name: "Teekam", age: 25 };
Includes:
- Array →
let arr = [1, 2, 3]; - Function →
function greet() { return "Hi"; }
💡 In Short:
JavaScript data types are —
Primitive: String, Number, Boolean, Undefined, Null, Symbol, BigInt
Non-Primitive: Object (includes arrays & functions).