Lodash – zip method

  • Post author:
  • Post category:Lodash
  • Post comments:2 Comments
Lodash - zip method

Syntax Of Lodash zip method

_.zip([arrays])

The Lodash zip method creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second element of the given arrays, and so on.

Arguments

  • [arrays] (…Array) − The arrays to process.

Output

  • (Array) − Returns the new array of grouped elements.

Example

var _ = require('lodash');
 
var result = _.zip(['a', 'b'], [1, 2], [true, false]);
console.log(result);

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

Command

\>node tester.js

Output

[ [ 'a', 1, true ], [ 'b', 2, false ] ]

Next Topic – Click Here

This Post Has 2 Comments

Leave a Reply