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

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 학습자의 빠른 성장을 도와주세요!