What is the difference between null and undefined in JavaScript?

前端 未结 30 3278
夕颜
夕颜 2020-11-21 23:06

I want to know what the difference is between null and undefined in JavaScript.

30条回答
  •  盖世英雄少女心
    2020-11-21 23:42

    null is a special value meaning "no value". null is a special object because typeof null returns 'object'.

    On the other hand, undefined means that the variable has not been declared, or has not been given a value.

提交回复
热议问题