admin管理员组

文章数量:1391999

Why typeof NULL is return undefined while typeof null return object ?

Check this snippet

console.log(typeof NULL)// undefined 

console.log(typeof null)// object 

Why typeof NULL is return undefined while typeof null return object ?

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
Add a ment  | 

3 Answers 3

Reset to default 7

JavaScript 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