for in
const array = [1, 2, 3, 4, 5, 6]
for (let index = 0; index < array.length; index++) {
const element = array[index]
console.log(element)
}
forEach
array.forEach((item, index, array) => {
console.log(array)
})
filter
array.filter((item, index, array) => {
console.log(array)
})
map
array.map((item, index, array) => {
console.log(array)
})
reduce
array.reduce((item, index, array) => {
console.log(array)
})
some
array.some((item, index, array) => {
console.log(array)
})
every
array.every((item, index, array) => {
console.log(array)
})
find
array.find((item, index, array) => {
console.find(array)
})
findIndex
array.find((item, index, array) => {
console.find(array)
})
来源:https://blog.csdn.net/small_ff/article/details/98726861