Group array of object nesting some of the keys with specific names

This can be done with a clever combinartion of _.map and _.groupBy. const items = [ { tab: ‘Results’, section: ‘2017’, title: ‘Full year Results’, description: ‘Something here’, }, { tab: ‘Results’, section: ‘2017’, title: ‘Half year Results’, description: ‘Something here’, }, { tab: ‘Reports’, section: ‘Marketing’, title: ‘First Report’, description: ‘Something here’, } ]; … Read more

How can I group an array of objects by key?

In plain Javascript, you could use Array#reduce with an object var cars = [{ make: ‘audi’, model: ‘r8’, year: ‘2012’ }, { make: ‘audi’, model: ‘rs5’, year: ‘2013’ }, { make: ‘ford’, model: ‘mustang’, year: ‘2012’ }, { make: ‘ford’, model: ‘fusion’, year: ‘2015’ }, { make: ‘kia’, model: ‘optima’, year: ‘2012’ }], result = … Read more