IE 10 以下 , setTimeout and setInterval 奇怪现象
caihuiji opened this issue · 1 comments
caihuiji commented
loskael commented
参考 imweb/tryjs#4
在浏览器环境下 window.setTimeout === setTimeout;
在 IE6-9 下, setTimeout 是只读的, window 是可写的, 重写 window.setTimeout 将会导致 以上等式不成立
以下代码结果为上述浏览器下的测试结果
typeof window.setTimeout; // object
window.setTimeout === setTimeout; // true
var temp = window.setTimeout;
window.setTimeout = function(fn, delay){
return temp(fn, delay);
};
typeof window.setTimeout; // function
window.setTimeout === setTimeout; // false
temp === setTimeout; // true
typeof window.xxx; // undefined
window.xxx = 'hehe';
typeof window.xxx; // string
window.xxx; // hehe
xxx; // hehe