JavaScript中的 typeof,null,和undefined

typeof操作符

null

在JavaScript中null表示“什么都没有”。

null是一个只有一个值的特殊类型。表示一个空对象引用。

typeof null; 返回的是object

undefined

在JavaScript中undefined是一个没有设置值的变量。

var p = undefined;  //值为undefined(空),类型是undefined。

可以为变量赋undefined,用来清空变量。

猜你喜欢

转载自www.cnblogs.com/1016391912pm/p/11793164.html