Primitives: string, number, boolean, null, undefined, symbol, bigint. Objects (including arrays and functions) are reference types.
typeof quirks
typeof null === 'object' is a long-standing bug—check value === null explicitly.
Comparisons
Use === and !== (strict) instead of == which coerces types.
Important interview questions and answers
- Q: typeof null?
A: Returns 'object'—use strict null checks. - Q: Number pitfalls?
A: IEEE floats—0.1 + 0.2 !== 0.3 exactly; use rounding or integers for money.
Self-check
- List five primitive types.
- Why prefer === over ==?
Tip: Use Number.isNaN(x) instead of x === NaN.
Interview prep
- typeof null?
Returns 'object'—use explicit null checks.