const inventory = [
{ name: "芦笋", type: "蔬菜", quantity: 5 },
{ name: "香蕉", type: "水果", quantity: 0 },
{ name: "山羊", type: "肉", quantity: 23 },
{ name: "樱桃", type: "水果", quantity: 5 },
{ name: "鱼", type: "肉", quantity: 22 },
];
const groupEd=Object.groupBy(inventory,i=>{
console.log(i)
return i.type
})
console.log(groupEd,"groupEd")
前端工程师、程序员

浙公网安备 33010602011771号