let arr = [1, 2, 3, 4, 5]
arr.push(6)
console.log(arr); //=>[1, 2, 3, 4, 5, 6]
let arr = [1, 2, 3, 4, 5]
arr.unshift(0)
console.log(arr); //=>[0, 1, 2, 3, 4, 5]
let arr = [1, 2, 3, 4, 5]
arr.pop()
console.log(arr); //=>[1, 2, 3, 4]
let arr = [1, 2, 3, 4, 5]
arr.shift()
console.log(arr); //=>[2, 3, 4,5]
let arr = [1, 2, 3, 4, 5]
arr.reverse()
console.log(arr); //=>[5,4, 3, 2, 1]
let arr = [1, 2, 3, 4, 5]
arr.splice(2, 2, 2, 2)
console.log(arr); //=>[1, 2, 2, 2, 5]
let arr = [1, 2, 3, 4, 5]
arr.forEach((item, index) => {
console.log(item, index); //=>0,1 1,2 2,3 3,4 4,5
})
let arr = [1, 2, 3, 4, 5]
let a = arr.filter(item => item > 2)
console.log(a); //=>[3, 4, 5]
let arr = [1, 2, 3, 4, 5]
let a = arr.some(item => item > 2)
console.log(a); //=>true
let arr = [1, 2, 3, 4, 5]
let a = arr.every(item => item > 2)
console.log(a); //=>false
let arr = [1, 2, 3, 4, 5]
let a = arr.map(item => item + 2)
console.log(a); //=>[3, 4, 5, 6, 7]
let arr = [1, 2, 3, 4, 5]
let a = arr.find(item => item > 2)
console.log(a); //=>3
let arr = [1, 2, 3, 4, 5]
let a = arr.findIndex(item => item > 2)
console.log(a); //=>2
let arr = [1, 2, 3, 4, 5]
let a = arr.includes(2)
console.log(a); //=>true
let arr = [1, 2, 3, 4, 5]
let a = arr.slice(1, 3)
console.log(a) //=>[2, 3]
原文:https://www.cnblogs.com/yuhuo123/p/15116367.html