I am developing an application on AngularJS (1) and I can not figure out how to split array of items in another array group by item.
I mean I have an array of different
You can use reduce and Object.values()
reduce
Object.values()
let a = [ {"name": "toto", "uuid": 1111}, {"name": "tata", "uuid": 2222}, {"name": "titi", "uuid": 1111} ]; let b = Object.values(a.reduce((a,b) => { a[b.uuid] = a[b.uuid] ? a[b.uuid].concat(b) : [b]; return a; }, {})); console.log(b);