Lodash - unzip method



Syntax

_.unzip(array)

This method is like _.zip except that it accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.

Arguments

  • array (Array) − The array of grouped elements to process.

Output

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

Example

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

result = _.unzip(result);
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 ] ]
[ [ 'a', 'b' ], [ 1, 2 ], [ true, false ] ]
lodash_array.htm
Advertisements