var items = [1,2,3,4,5];
//item代表数组的单个元素,index代表索引,arr代表源数组
items.forEach(function(item,index,arr) {
console.log(index + ":" + item + "->" + arr);
})
//输出
// 0:1->1,2,3,4,5
// 1:2->1,2,3,4,5
// 2:3->1,2,3,4,5
// 3:4->1,2,3,4,5
// 4:5->1,2,3,4,5
var items = [1,2,3,4,5];
//item代表数组的单个元素,index代表索引,arr代表源数组
items.forEach(function(item,index,arr) {
console.log(index + ":" + item + "->" + arr);
})
//输出
// 0:1->1,2,3,4,5
// 1:2->1,2,3,4,5
// 2:3->1,2,3,4,5
// 3:4->1,2,3,4,5
// 4:5->1,2,3,4,5