Why is null an object and what's the difference between null and undefined?

后端 未结 22 1075
猫巷女王i
猫巷女王i 2020-11-22 02:58

Why is null considered an object in JavaScript?

Is checking

if ( object == null )
      Do something

the

22条回答
  •  误落风尘
    2020-11-22 03:57

    Look at this:

       
                                              //return:
        //undefined    null    false
       //object       null    false
        //string               false
          //number               false
           //number               true
         //string               true
    

提交回复
热议问题