groupBy = (xs, key) => {
return xs.reduce((rv, x) => {
(rv[x[key]] = rv[x[key]] || []).push(x)
return rv
}, {})
}
一个分组好用的函数
最新推荐文章于 2022-06-14 17:17:14 发布
groupBy = (xs, key) => {
return xs.reduce((rv, x) => {
(rv[x[key]] = rv[x[key]] || []).push(x)
return rv
}, {})
}