Lodash – unzip With methods

  • Post author:
  • Post category:Lodash
  • Post comments:2 Comments
Lodash - unzip With methods

Syntax Of Lodash unzip With methods

_.unzipWith(array, [iteratee=_.identity])

This Lodash unzip With methods is like _.unzip except that it accepts iteratee to specify how regrouped values should be combined. The iteratee is invoked with the elements of each group: (…group).

Arguments

  • array (Array) โˆ’ The array of grouped elements to process.
  • [iteratee=_.identity] (Function) โˆ’ The function to combine regrouped values.

Output

  • (Array) โˆ’ Returns the new array of regrouped elements.

Example

var _ = require('lodash');
var result = _.zip([1, 2], [10, 20]);
console.log(result);

result = _.unzipWith(result, _.add);
console.log(result);

Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

Output

[ [ 1, 10 ], [ 2, 20 ] ]
[ 3, 30 ]

Next Topic – Click Here

This Post Has 2 Comments

Leave a Reply