let的时候,AO是怎么找的?
var arr = [{a:'A'},{a:'A'},{a:'A'}]
for(let i = 0,len = arr.length; i<len; i++) {
arr[i].fun = function(){
console.log(i)
}
}
arr[0].fun() //0
arr[1].fun() //1
arr[2].fun() //2
var arr = [{a:'A'},{a:'A'},{a:'A'}]
for(let i = 0,len = arr.length; i<len; i++) {
arr[i].fun = function(){
console.log(i)
}
}
arr[0].fun() //0
arr[1].fun() //1
arr[2].fun() //2
2021-10-21
举报