数组
(1,2,3,4,5,6).forEach((item,index)=>{//item是数组的每一项 index表式索引
console.log(item,index);
})
对象
var obj=[
{id:1,name:apple,price:10},
{id:2,name:banner,price:20},
{id:3,name:orgine,price:30},
{id:4,name:西瓜,price:40},
]
obj.forEach((item,index)=>{//item是数组的每一项 index表式索引
console.log(item.name);//获取每项的名字
})