What is the difference between null and undefined in JavaScript?

前端 未结 30 3339
夕颜
夕颜 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 - It is an assignment value, which is used with variable to represent no value (it's an object).

    undefined - It is a variable which does not have any value assigned to it, so JavaScript will assign an undefined to it (it's a data type).

    undeclared - If a variable is not created at all, it is known as undeclared.

提交回复
热议问题