In my last post, I looked into some JavaScript casting and explored why 0 <= null evaluates as true. For this post, I’d like to investigate another unexpected behavior in JavaScript: why typeof(null) evaluates as 'object'. This is a well-known bug, and we’ll investigate first in the ECMAScript specification followed by a deep dive into an early implementation of JavaScript to see the bug in its natural habitat. The main idea is that the code assigned each item some bits for use as flags f...