TIL: null is an object in Javascript

I’ve been in a lull about learning concepts related to programming and web development the past few months so yesterday when I got an email about Just Javascript, I signed up for the course to check out how it will be.

So far, I’m running into pleasant surprises like how there are only nine data types in Javascript.

  1. Numbers (1, 3.14, -500)
  2. Strings (“hello”, ‘samson’, ‘a long sentence’)
  3. Booleans (true and false)
  4. Undefined (undefined)
  5. Null (null)
  6. BigInts (not sure about these yet)
  7. Objects ({})
  8. Functions (sum => x + x)
  9. Symbols (uncommon but used for referring to unchanging values)

Well, after learning about these, I also ran into an interesting quiz question in the course, what is the value of null when checking with typeof()? Turns out it’s "object". This was a surprise to me but I guess it’s been a bug for a long time.

Here’s a lot more info about it from someone who knows JS way better than me:

The history of “typeof null”.