forEach()方法
对数组进行遍历循环,对数组中的每一项运行指定的函数
格式:
arr.forEach(function(value, index) {})
var arr = [1, 3, 5, 7, 9, 11];
arr.forEach(function(value, index) {
console.log(index + ":" + value)
})
forEach()方法
对数组进行遍历循环,对数组中的每一项运行指定的函数
格式:
arr.forEach(function(value, index) {})
var arr = [1, 3, 5, 7, 9, 11];
arr.forEach(function(value, index) {
console.log(index + ":" + value)
})