var shoppingCart = [{
id: 0,
name: 'Mens Shirt',
price: 20,
size: 'Large'
}, {
id: 1,
name: 'kids shirt',
price: 15,
size: 'small'
}]
答案 0 :(得分:0)
您可以像这样简单地使用Array.prototype.forEach
:
var shoppingCart = [{
id: 0,
name: 'Mens Shirt',
price: 20,
size: 'Large'
}, {
id: 1,
name: 'kids shirt',
price: 15,
size: 'small'
}]
shoppingCart.forEach(item => console.log(item.name));