1、map(映射)
let arr=[1,2,3,4,5]
arr.map(item=>{
alert(item)
})
2、reduce(汇总)
let arr=[1,2,3]
let a=arr.reduce((temp,num,index)=>{
return temp+num
})
alert(a)
3、filter(过滤器)
let arr=[1,2,3]
let a=arr.filter(item=>{
if(item%2==1){
return true
}else{
return false
}
})
alert(a)
/*********************************/
let arr=[
{title:'1',price:'111'},
{title:'2',price:'222'},
{title:'3',price:'333'},
{title:'4',price:'444'}
]
let a=arr.filter(json=>json.price>300)
console.log(a)
4、forEach(循环(迭代))
let arr=[1,2,3,4]
arr.forEach((item,index)=>{
alert(index+':'+item)
})