Null 类型
Null 类型是第二个只有一个值的数据类型,这个特殊的值是 null 。
从逻辑角度来看, null 值表示一个空对象指针,而这也正是使用 typeof 操作符检测 null 值时会返回 "object" 的原因。
undefined 值是派生自 null 值的,因此 ECMA-262规定对它们的相等性测试要返回 true :
alert(null == undefined); //true
尽管 null 和 undefined 有这样的关系,但它们的用途完全不同。
只要意在保存对象的变量还没有真正保存对象,就应该明确地让该变量保存 null 值。这样做不仅可以体现 null 作为空对象指针的惯例,而且也有助于进一步区分 null 和 undefined 。