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

后端 未结 22 1316
猫巷女王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:31

    In Javascript null is not an object type it is a primitave type.

    What is the difference? Undefined refers to a pointer that has not been set. Null refers to the null pointer for example something has manually set a variable to be of type null

提交回复
热议问题