JavaScript中undefined和null有什么不同?

2020-02-05  本文已影响0人  moyahuang

The fundamental difference between undefined and null is that, in JavaScript, undefined means a variable has been declared (or not declared), but has not yet been assigned a value. On the other hand, null is an assignment value. It can be assigned to a variable as a representation of no value.

简单来说,undefined是变量被声明但未被赋初始值的状态;null是有初始值,初始值为空的状态。

上一篇下一篇

猜你喜欢

热点阅读