js关于for循环中的闭包问题

由于js没有块级做用域for循环的循环体不是一个做用域你的第一段代码等效于如下展开web var arr=[]; var i=0; arr.push(function(){console.log(i);}); i++; arr.push(function(){console.log(i);}); i++; arr.push(function(){console.log(i);}); i++; a
相关文章
相关标签/搜索