joken-前端工程师

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::
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")
posted on 2024-08-01 21:12  joken1310  阅读(24)  评论(0)    收藏  举报