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