und : 表示个未声明变量
或已声明但没有赋值变量
或个并不存在对象属性
运算符将两者看作相等如果要区分两者要使用=或typeof运算符
————————————-默默无闻分割线——————————————–
在JavaScript中null和und度使人迷惑下面分析有利于你更清晰认知它(或者让你更迷惑):
- null是关键字;und是Global对象个属性
- null是对象(空对象, 没有任何属性和思路方法);und是und类型值试试下面代码:
document.writeln(typeof null); // object
document.writeln(typeof und); // und- 对象模型中所有对象都是Object或其子类例子但null对象例外:
document.writeln(null instanceof Object); // false- null”等值()”于und但不”全等值(=)”于und:
document.writeln(null und); // true
document.writeln(null = und); // false- 运算时null和und都可以被类型转换为false但不等值于false:
document.writeln(!null, !und); // true,true
document.writeln(nullfalse); // false
document.writeln(undfalse); // false
最新评论