<script type="text/javascript">
function buildList(list) {
var result = [];
for (var i = 0; i < list.length; i++) {
var item = 'item' + list[i];
result.push( function() {console.log(item + ' ' + list[i])} );
}
return result;
}
function testList() {
var fnlist = buildList([1,2,3]);
fnlist[0]();
}
testList();
</script>
问题:
在 firefox->console 中,它显示item3 undefined
,为什么?