Lodash – zipWith method

  • Post author:
  • Post category:Lodash
  • Post comments:0 Comments
Lodash - zipWith method

Syntax Lodash zipWith method

_.zipWith([arrays], [iteratee=_.identity])

This Lodash zipWith method is like _.zip except that it accepts iteratee to specify how grouped values should be combined. The iteratee is invoked with the elements of each group: (…group).

Arguments

  • [arrays] (…Array) โˆ’ The arrays to process.
  • [iteratee=_.identity] (Function) โˆ’ The function to combine grouped values.

Output

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

Example

var _ = require('lodash');
 
var result = _.zipWith([1, 2], [10, 20], function(a, b) {
   return a + b;
});
console.log(result);

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

Command

\>node tester.js

Output

[ 11, 22 ]

Next Topic – Click Here

Leave a Reply