美文网首页
JavaScript中undefined和null有什么不同?

JavaScript中undefined和null有什么不同?

作者: moyahuang | 来源:发表于2020-02-05 11:26 被阅读0次

    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是有初始值,初始值为空的状态。

    相关文章

      网友评论

          本文标题:JavaScript中undefined和null有什么不同?

          本文链接:https://www.haomeiwen.com/subject/ydojxhtx.html