null
在JavaScript中null表示"什么都没有"。
null是一个只有一个值的特殊类型。表示一个空对象引用。
Note用typeof检测null返回是object。
你可以设置为null来清空对象:
实例
var person = null; // 值为 null(空), 但类型为对象
你可以设置为undefined来清空对象:
实例
var person = undefined; // 值为 undefined, 类型为 undefined
undefined
在JavaScript中,undefined是一个没有设置值的变量。
typeof一个没有值的变量会返回undefined。
实例
var person; // 值为 undefined(空), 类型是undefined
任何变量都可以通过设置值为undefined来清空。类型为undefined.
实例
person = undefined; // 值为 undefined, 类型是undefined
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h63853.shtml