The use case is to convert an array of objects into a hash map based on string or function provided to evaluate and use as the key in the hash map and val
Using ES6 spread + Object.assign:
array = [{key: 'a', value: 'b', redundant: 'aaa'}, {key: 'x', value: 'y', redundant: 'zzz'}] const hash = Object.assign({}, ...array.map(s => ({[s.key]: s.value}))); console.log(hash) // {a: b, x: y}