Why is typeof null “object”?

前端 未结 8 1268
暗喜
暗喜 2020-11-22 04:51

I\'m reading \'Professional Javascript for Web Developers\' Chapter 4 and it tells me that the five types of primitives are: undefined, null, boolean, number and string.

相关标签:
8条回答
  • 2020-11-22 05:33

    In JavaScript, typeof null is 'object', which incorrectly suggests that null is an object. This is a bug and one that unfortunately can't be fixed, because it would break existing code.

    0 讨论(0)
  • 2020-11-22 05:33

    For people who interested in some code that made this behaviour this is the link for you guys....

    why typeof null is object with the implementation

    0 讨论(0)
提交回复
热议问题