0
阵列中的我有对象的数组:集团通过对象的数量在香草的Javascript
[{person:101, year: 2012}, {person:102, year: 2012}, {person:103, year: 2013}]
而且我希望能够通过SQL返回的总次数每年(很像组将实现)的格式为:
[{year: 2012, count:2}, {year: 2013, count:1}]
在Vanilla Javascript中实现此目的的最佳方法是什么?
会更有用的输出格式不'{ “2012” :2,“2013”:1}'?因为这将*很容易通过一个简单的循环实现;) –
检查[that](http://stackoverflow.com/questions/5667888/counting-the-occurrences-of-javascript-array-elements)并且有下次尝试。你有谷歌,甚至没有尝试? – Sylogista