Skip to content

Instantly share code, notes, and snippets.

@rc1021
Last active December 14, 2017 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rc1021/b7d6a4cf4776ad3dcd1d237e810b8cb5 to your computer and use it in GitHub Desktop.
Save rc1021/b7d6a4cf4776ad3dcd1d237e810b8cb5 to your computer and use it in GitHub Desktop.
let _ = require('lodash');
//Input
var input = [
{ key: '1', val: 'a' },
{ key: '2', val: 'b' },
{ key: '3', val: 'c' }
];
//Desired output
{
'1': 'a',
'2': 'b',
'3': 'c'
}
//Current best solution
_.fromPairs(_.map(input, i => [i.key, i.val]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment