The history of “typeof null”
Update 2013-11-05: I take a look at the C code of typeof to better explain why typeof null results in 'object' . In JavaScript, typeof null is 'object' , which incorrectly suggests that null is an object (it isn’t, it’s a primitive value, consult my blog post on categorizing values for details). This is a bug and one that unfortunately can’t be fixed, because it would break existing code. Let’s explore the history of this bug. The “typeof null” bug is a remnant from the first version of JavaScript. In this version, values were stored in 32 bit units, which consisted of a small type tag (1–3 bits) and the actual data of the value. The type tags were stored in the lower bits of the units. There were five of them: 000: object. The data is a reference to an object. 1: int. The data is a 31 bit signed integer. 010: double. The data is a reference to a double floating point number. 100: string. The data is a reference to a string. 110...