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
With lodash:
lodash
const items = [ { key: 'foo', value: 'bar' }, { key: 'hello', value: 'world' } ]; const map = _.fromPairs(items.map(item => [item.key, item.value])); console.log(map); // { foo: 'bar', hello: 'world' }
Link to lodash