admin管理员组文章数量:1355703
I was studying the Twitter source code, and I came across the following snippet:
window.setTimeout=window.setTimeout;window.setInterval=window.setInterval;
Why does Twitter redefine these functions?
Edit: To see the code, go to any twitter user page, open the source of the page, and you will see that snippet in the second block of javascript.
I was studying the Twitter source code, and I came across the following snippet:
window.setTimeout=window.setTimeout;window.setInterval=window.setInterval;
Why does Twitter redefine these functions?
Edit: To see the code, go to any twitter user page, open the source of the page, and you will see that snippet in the second block of javascript.
Share Improve this question edited Nov 8, 2011 at 0:19 jonathancardoso asked Nov 8, 2011 at 0:07 jonathancardosojonathancardoso 12.8k8 gold badges54 silver badges73 bronze badges 1- What's the context? I don't think this question is answerable without a link to the full code. – nrabinowitz Commented Nov 8, 2011 at 0:12
1 Answer
Reset to default 15This is a technique to replace setTimeout
and setInterval
functions globally in a cross-browser fashion.
window.setTimeout
, when used as an lvalue (on the left side of the assignment), does not walk the prototype chain, but on the right side, it does. So this will always pull a property out of the prototype chain and put it right on the object.
See http://www.adequatelygood./2011/4/Replacing-setTimeout-Globally.
本文标签: javascriptWhy does Twitter redefine windowsetTimeout and windowsetIntervalStack Overflow
版权声明:本文标题:javascript - Why does Twitter redefine window.setTimeout and window.setInterval? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744033853a2579403.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论