es6 中forEach()的用法
var myArr=[
{id:1,name:“sdf”},
{id:2,name:“dfsdf”},
{id:3,name:“fff”}
]
myArr.forEach((item,index)=>{
console.log(item.id);
//1,2,3
})
就是这样的
array.forEach(element => {
});
var myArr=[
{id:1,name:“sdf”},
{id:2,name:“dfsdf”},
{id:3,name:“fff”}
]
myArr.forEach((item,index)=>{
console.log(item.id);
//1,2,3
})
array.forEach(element => {
});