我刚刚在 ie8 中发现了非常有趣的行为。事实证明,null 并不总是 null。
// just normal, casual null hanging out in the sun
var nullA = null;
// query for non existing element, should get null, same behaviour also for getElementById
var nullB = document.querySelector('asdfasfdf');
// they are equal
console.log(nullA === nullB);
// false
nullA instanceof Object;
// will throw 'Object expected' error in ie8. Black magic
nullB instanceof Object;
有人对此有解释吗?