SyntaxFix
Write A Post
Hire A Developer
Questions
With lodash, this can be done using keyBy:
var arr = [ { key: 'foo', val: 'bar' }, { key: 'hello', val: 'world' } ]; var result = _.keyBy(arr, o => o.key); console.log(result); // Object {foo: Object, hello: Object}