Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
“What's the typeof null?”, and other confusing JavaScript Types (bitsofco.de)
2 points by _9w7z on March 12, 2017 | hide | past | favorite | 1 comment


No, 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.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: