admin管理员组文章数量:1391999
Why
typeof NULL
is returnundefined
whiletypeof null
returnobject
?
Check this snippet
console.log(typeof NULL)// undefined
console.log(typeof null)// object
Why
typeof NULL
is returnundefined
whiletypeof null
returnobject
?
Check this snippet
console.log(typeof NULL)// undefined
console.log(typeof null)// object
Share
Improve this question
edited Aug 2, 2018 at 8:21
leogoesger
3,8407 gold badges38 silver badges74 bronze badges
asked Aug 2, 2018 at 7:52
Ramesh RajendranRamesh Rajendran
38.7k49 gold badges159 silver badges240 bronze badges
1
- isn't that because js is case-sensitive? safaribooksonline./library/view/javascript-the-definitive/… – leogoesger Commented Aug 2, 2018 at 7:54
3 Answers
Reset to default 7JavaScript is case-sensitive, so they are two different things:
NULL
is a variable, which is not defined.
null
is the null-object.
JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters. The while keyword, for example, must be typed “while”, not “While” or “WHILE”. Similarly, online, Online, OnLine, and ONLINE are four distinct variable names.
So NULL
is a variable that you have not defined yet, whereas null
is
The value null represents the intentional absence of any object value.
To read more:
https://www.safaribooksonline./library/view/javascript-the-definitive/0596000480/ch02s02.html
https://developer.mozilla/en-US/docs/Web/JavaScript/Reference/Global_Objects/null
NULL and null do not reppresent the same thing, since it is case sensitive.
Check here the reference:
https://developer.mozilla/en-US/docs/Web/JavaScript/Reference/Global_Objects/null
本文标签: javascriptWhy typeof NULL is return undefinedStack Overflow
版权声明:本文标题:javascript - Why typeof NULL is return undefined? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744679111a2619290.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论