数组常用方法:forEach,filter,map,find,reduce
1.forEach
const arr=[1,2,3,4,5]
const arr1=[]
arr.forEach((item=>{
arr1.push(item)
}))
console.log(arr);
console.log(arr1);
2.filter
const arr2=[1,2,3,4,5,7]
const arr3=arr2.filter((item)=>item<5)
console.log(arr3);
3.map
const arr4=[1,2,3,4,5,6,7]
const arr5=arr4.map((item)=>item+7)
console.log(arr5);
4.find
const arr6= [4, 9, 16, 25];
const arr7=arr6.find((item)=>item>10)
console.log(arr7);
5.reduce
const arr6= [4, 9, 16, 25];
const arr7=arr6.reduce((sum, number)=>{
return sum+number
},0)
console.log(arr7);