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.
- Numbers (1, 3.14, -500)
- Strings (“hello”, ‘samson’, ‘a long sentence’)
- Booleans (
true
andfalse
) - Undefined (
undefined
) - Null (
null
) - BigInts (not sure about these yet)
- Objects (
{}
) - Functions (
sum => x + x
) - 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:
Comments ()