I cant't see it in the docs - http://lodash.com/docs - please help me:
What is the opposite of _.pairs()
? There must be one - I just cant' see where!
The goal is to produce key/value pairs from an array of the form [['key1':'value1'], ['key2':'value2'], ...]
Not that I really need it a lib for that: I just like to re-use things..
isEqual() Method. The Lodash _. isEqual() Method performs a deep comparison between two values to determine if they are equivalent. This method supports comparing arrays, array buffers, boolean, date objects, maps, numbers, objects, regex, sets, strings, symbols, and typed arrays.
Overview. The _. get() method in Lodash retrieves the object's value at a specific path. If the value is not present at the object's specific path, it will be resolved as undefined . This method will return the default value if specified in such a case.
If both arrays are in the correct order; where each item corresponds to its associated member identifier then you can simply use. var merge = _. merge(arr1, arr2);
The Lodash _. noop() method is used to return “undefined” irrespective of the arguments passed to it. Syntax: _.noop() Parameters: This method can take optional parameters of any type. Returns: This method returns undefined.
I think you're looking for _.object
/_.zipObject
.
http://lodash.com/docs#zipObject
"use strict"; var obj, pairs, objResult; obj = { key1: "value1", key2: "value2" }; pairs = _.pairs(obj); objResult = _.object(pairs); // The original object. console.log(obj); // The object as an array of arrays. console.log(pairs); // The array of arrays converted back to the original object. console.log(objResult);
http://jsfiddle.net/HmDk6/
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