javascript - JS 的循环引用, 原因是什么?
ringa_lee
ringa_lee 2017-04-10 12:45:39
0
5
878

Mozilla 文档上的例子, 这个是在 IE 6,7 里的,
https://developer.mozilla.org/en-US/docs/JavaScript/Memory_Management

var p = document.createElement("p");
p.onclick = function(){
  doSomething();
}; // The p has a reference to the event handler via its 'onclick' property
// The handler also has a reference to the p since the 'p' variable can be accessed within the function scope
// This cycle will cause both objects not to be garbage-collected and thus a memory leak.

这里说的, 函数里有一个对 p 的引用, 可是在哪, 是 this 么?
在 Chrome Firefox 里是否有类似的内存泄漏问题?
这是语言设计的失误么?

ringa_lee
ringa_lee

ringa_lee

全部回复(5)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!