I am using Lodash to create an object from an array but the result is not what I expected. Here is the code:
var _ = require('lodash');
var data = [
[ 'creds', 'ZHRyYWhlZMMKDWhzYW5EaG1hZDE=' ],
[ 'loggedIn', true ],
];
var result = _.zipObject(data);
Now the result is:
{creds,ZHRyYWhlZMMKDWhzYW5EaG1hZDE=: undefined, loggedIn,true: undefined}
but what I need is:
{'creds':'ZHRyYWhlZMMKDWhzYW5EaG1hZDE=', 'loggedIn':true}
Using lodash's _.fromPairs:
var result = _.fromPairs(data);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With