数组遍历方法
let arr = [1, 2, 3, 3]
arr.some((item)=>{ retrue item === 3 })
arr.every((item)=>{ retrue item === 3 })
for(var i = 0, j = arr.length; i < j; i+=1) {
console.log(arr[i])
}
for(var key in arr) {
console.log(key)
}
for(var key of arr) {
console.log(key)
}
arr.forEach(function (item, idnex, array) {
console.log(item)
console.log(array)
})
var newArr = arr.map(function (item, idnex) {
return item * item
})
console.log(newArr)
var newArr = arr.filter(function (item, index) {
return item>2
})
console.log(newArr)
var num = arr.find(function (item, index) {
return item === 3
})
console.log(num)
var num = arr.findIndex(function (item) {
return item === 3
})
console.log(num)