Thursday, October 23, 2025
HomeLanguagesJavascriptLodash _.unzip() Method

Lodash _.unzip() Method

The _.unzip method is similar to _.zip (i.e.; it creates an array of grouped elements) except that it accepts an array of grouped elements and also creates an array regrouping the elements to their pre-zip configuration.

Syntax:

_.unzip(array)

Parameters: This method accepts a single parameters as mentioned above and described below:

  • array (Array): This parameter holds the array of grouped elements to process.

Return Value: This method is used to returns the new array of regrouped elements.

Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.

javascript




// Requiring the lodash library 
const _ = require("lodash"); 
      
// Original array 
var zipped = _.zip(['a', 'b'], [1, 2], [true, 
  
false]);    
  
// Use of _.zip() 
// method
let gfg = _.zip(zipped);
      
// Printing the output 
console.log(gfg);


Output:

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

Example 2:

javascript




// Requiring the lodash library 
const _ = require("lodash"); 
      
// Original array 
var zipped = (['x', 'y'], [5, 6], [true, false]);    
  
// Use of _.zip() 
// method
let gfg = _.zip(zipped);
      
// Printing the output 
console.log(gfg);


Output:

[ [true, false] ]

Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS