What data types does JavaScript have?
By FrontendPro Editorial Team Updated 9/26/2026
Answer
Seven primitives and one object type.
Primitives — immutable, compared by value:
string, number, boolean, undefined, null, symbol, bigint
Objects — mutable, compared by reference: plain objects, arrays, functions, Date, Map, Set, RegExp and everything else.
typeof "hi"; // "string"
typeof 42; // "number"
typeof 10n; // "bigint"
typeof Symbol(); // "symbol"
typeof undefined; // "undefined"
typeof null; // "object" ← a long-standing bug, kept for compatibility
typeof []; // "object" ← use Array.isArray()
typeof (() => {}); // "function" ← functions are objects with a special typeof
null vs undefined
undefined means "no value has been assigned" — the engine produces it. null means "deliberately empty" — you produce it. A missing function argument is undefined; a cleared field is usually null.
Numbers
There is one number type, a 64-bit float, so 1 and 1.0 are identical and 0.1 + 0.2 === 0.3 is false. Integers are exact only up to Number.MAX_SAFE_INTEGER (about 9×10¹⁵); beyond that use bigint. NaN is a number, and it is the only value not equal to itself — test with Number.isNaN.
Value vs reference
let a = { n: 1 };
let b = a;
b.n = 2;
a.n; // 2 — same object
let x = 1, y = x;
y = 2;
x; // 1 — copied
This one distinction explains most confusion about copying, equality and why [] === [] is false.
Type coercion is the other half of the story: == converts before comparing, === does not. Use === unless you specifically want == null to catch both null and undefined.
