解决for循环引用i指向问题 function test () { var arr = []; for (var i = 0; i < 10; i++) { arr[i] = function () { document.write(i + ' '); } } return arr; } var myArr = test(); for (var j = 0; j < 10; j++) { myArr[j]