一段防止闭包的javascript代码
<script>
var test={};
test.doo=function(i){
alert("时间到了,我要做点事情。"+i);
};
Function.prototype.createCallback=function(){
var that=this;
var args=[].slice.apply(arguments);
return function(){ that.apply(null,args);
};
};
window.onload=function(){
var memory="";
var i=1;
for(i=0;i<10000;i++) memory+="eat memory";
setTimeout (test.doo.createCallback(i),50000);
}
</script>