You've typed typeof ten thousand times. You've been lied to more often than you realise. Over the next seven screens, you'll build a type-detector you can actually trust — one wall at a time. Every wall is a bug you've shipped or nearly shipped. Start here: a one-line helper a teammate just merged. function isObject(x) { return typeof x === 'object' }. Reasonable. Passes the demo. A week later the tracker has eight bugs with the same shape — isObject([1, 2, 3]) is true, isObject(null) is true and the next .property access throws, isObject(new Date()) is true and Object.keys returns an empty array. One line, eight bugs, and the bug lives inside a single operator.

That operator is typeof. You learned it on day one. The mental model you walked away with is “tells me what something is.” What it actually does — ECMA-262 §13.5.3 — is return one of exactly eight strings and lie for five of the ten most common inputs in a React app. Watch what happens when you feed it those ten.

typeof workbench
scanned 0/8
Input tray
Runtime mirror · liveneedle resting
1
// Eight values. One needle. Watch how many times it lies.
2
3
→ typeof undefined      → ?
4
  typeof null          
5
  typeof 42            
6
  typeof 'hi'          
7
  typeof true          
8
  typeof [1, 2, 3]     
9
  typeof {}            
10
  typeof new Date()    
11
  typeof new Map()     
12
  typeof /foo/g        
13
14
// so far — truths: 0/8    lies: 0/8    still to scan: 8

The widget above does one thing: it runs typeof on whatever value you tap and shows the string you get back. The full return set is exactly eight: 'undefined', 'boolean', 'number', 'bigint', 'string', 'symbol', 'function', 'object'. Seven are primitives and functions. The eighth — 'object' — is the catch-all. Every non-primitive in the language falls into that one bucket.

Call the answer BEFORE you tap. Eight values are lined up. Some are primitives you'd expect to route cleanly. Some are the kinds of values you touch every day — arrays, dates, maps, regexes, null. Note which ones you're sure of and which ones you're guessing at. The guessing is the point.

Value 1 of 8committed: 0 / 8

Drop undefined onto the tray. Where does the needle swing — what does typeof return?