由于在IE的低版本中,JScript对象和COM对象时使用不一样的垃圾回收机制。闭包
由于在闭包中包含了包含函数的变量对象,若是咱们的闭包引用循环中引用函数
包含函数的变量对象中的引用时,只要匿名函数存在,该引用至少存在一次,spa
所以占用的内存永远也不会被释放。code
咱们平时写的一个例子:对象
function eve(){ var ele = document.getElementById("btn"); ele.onclick = function(){ console.log( ele.id ); } }
解决代码:blog
function eve(){ var ele = document.getElementById("btn"); var id = ele.id; ele.onclick = function(){ console.log( id ); }; ele = null; }