177. Implement Object.groupBy()

JavaScript

中等难度  -通过 / -执行

Object.groupBy() allows us to easily group array items, please try to implement it by yourself.

const items = [  {    id: 1,    kind: 'a',  },  {    id: 2,    kind: 'b',  },  {    id: 3,    kind: 'a',  }]const groups = Object.groupBy(items, ({kind}) => kind)// {//   a: [//     {//       id: 1,//       kind: 'a'//     },//     {//       id: 3,//       kind: 'a'//     }//   ],//   b: [//     {//       id: 2,//       kind: 'b'//     }//   ]// }

始终思考更好的解决办法