首先来看一下两者是怎么对待undefined的:
- alert(typeof undefined);
- alert(Object.prototype.toString.apply(undefined));
结果为:
undefined
[object Object]
由此看出,在Object.prototype.toString.apply眼里undefined也是Object。
接着来看一下是怎么对待null的:
- alert(typeof null);
- alert(Object.prototype.toString.apply(null));
结果为:
object
[object Object]
大家意见一致。typeof说:你可以不穿衣服来,但你一定要来!邪恶啊~