【发布时间】:2018-08-20 00:39:02
【问题描述】:
我有一个这样的数组
var array = [
{occurrences: 1, position: "1"},
{occurrences: 4, position: "2"},
{occurrences: 1, position: "1"},
{occurrences: 2, position: "3"},
];
我想这样总结:
{occurrences: 2, position: "1"},
{occurrences: 4, position: "2"},
{occurrences: 2, position: "3"}
我可以通过使用 lodash 或其他任何东西来实现这一点吗?
【问题讨论】:
-
是的,你可以。
标签: javascript lodash