Fundamentals / Data Types
Data Types
Seven primitives, and one type that isn't: object.
JavaScript has seven primitive types — String, Number, Boolean, Undefined, Null, BigInt, and Symbol — plus Object, which covers arrays, functions, and plain objects. Primitives are compared and copied by value. Objects are compared and copied by reference.
`typeof null` famously returns "object" — a decades-old bug that's now permanent, so never rely on `typeof` to detect null. Use `value === null` instead.
Codeeditable — Run and Step both follow your edits
Loading...
Console
Output will appear here
Visualization
Result
Press Step to watch each line's result appear here
Why?
typeof inspects the internal tag JavaScript stores alongside a value. null's tag was set to the same bit pattern as objects in the very first version of JS, and fixing it would break the web, so it stays.