3 ms·
“What's the typeof null?”, and other confusing JavaScript Types
- draw_down 10y agoNo, the type of `null` is null. I was unaware of the implementation detail mentioned here, but the reason `typeof null` returns "object" nowadays is because that's what the spec says. In other words, `typeof` will lie to you, and is kind of a crappy operator. (Also, FWIW, `function` is not a type. The type of a function is object, but this rarely comes up in real-world JS usage.)