H5 es6 foreach使用

数组.foreach(数组中的每一项,下标)=>{}

例如:

let arr=[

{id:1,name:'张三'},

{id:2,name:'李四'},

{id:3,name:'王五'}

]

arr.foreach(item,index)=>{

  console.log(item.id)   //1,2,3

}

posted on 2019-10-14 09:18  旺仔小裤头  阅读(892)  评论(0编辑  收藏  举报