我有一个数组:JS:组阵列由值嵌套数组
[
{
theme: "low battery",
Number: "S-10",
components: [ "hardware", "battery" ]
},
{
theme: "bad sync",
Number: "S-11",
components: [ "software" ]
},
{
theme: "misc troubles",
Number: "S-12",
components: [ "hardware", "software" ]
}
]
所以想要组这个数组由“组件”的值。换句话说,我想知道,组件在数组中发生了多少次。例如:
[
{
component: "hardware",
amount: 2
},
{
component: "software",
amount: 2
},
{
component: "battery",
amount: 1
}
]
的可能的复制[什么是GROUPBY对象的JavaScript的阵列上的最有效的方法?(https://stackoverflow.com/questions/14446511/what-is-the最有效的方法到对象上的一个javascript对象数组) – Andreas