What does typeof return for each kind of value? Which results surprise people, and how do you reliably check for an array or null?
Show the explanation
Model answer. typeof returns a string:
'string','number','bigint','boolean','symbol','undefined'for those primitives'function'for functions (including classes)'object'for everything else
The surprises:
typeof null === 'object'(a bug from the first version of the language)typeof [] === 'object', because arrays are objectstypeof NaN === 'number'
Reliable checks:
Array.isArray(value); // arrays
value === null; // null
Number.isNaN(value); // NaN (unlike the global isNaN, no coercion)
value instanceof Date; // a specific classtypeof is also the only safe way to test a name that may not be declared at all: typeof someGlobal === 'undefined' does not throw.
Original UniCircle question. Last reviewed 22 Oct 2026.
