The _.fromPairs()
method in Lodash creates an object composed of an array of key-value pairs.
_.fromPairs(array)
This method accepts the following parameters:
array
: This is the array containing the key-value pairs.This method returns an object.
Let’s look at an example of the _.fromPairs()
method in the code snippet below:
In the HTML tab:
lodash
script.In the JavaScript tab:
_.fromPairs()
method to create an object.In the output, we see an object composed of the key-value pairs of the array.
RELATED TAGS
CONTRIBUTOR
View all Courses