Sunday, November 23, 2025
HomeLanguagesJavascriptLodash _.zipObjectDeep() Method

Lodash _.zipObjectDeep() Method

The _.zipObjectDeep() method is similar to _.zipObject() method except that it supports property paths and also, it accepts two arrays, one of property identifiers and one of corresponding values.

Syntax:

_.zipObjectDeep([props=[]], [values=[]])

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

  • [props=[]] (Array): This parameter holds the property identifiers.
  • [values=[]] (Array): This parameter holds the property values.

Return Value: This method returns the new object.

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 obj1 = ['a.b[0].c', 'a.b[1].d'];
  
// Use of _.zipObjectDeep() method
  
let gfg = _.zipObjectDeep(obj1, [1, 2]);
  
// Printing the output 
console.log(gfg);


Output:

{ a: { b: [ [ object ], [object] ] } }

Example 2:

javascript




// Requiring the lodash library 
const _ = require("lodash"); 
      
// Original array 
  
var obj1 = ([ 40, 30, 90 ]);
  
// Use of _.zipObjectDeep() method
  
let gfg = _.zipObjectDeep(obj1, [ 1, 2, 3 ]);
  
// Printing the output 
console.log(gfg);


Output:

{ '30': 2, '40': 1, '90': 3 }

Example 3:

javascript




// Requiring the lodash library 
const _ = require("lodash"); 
      
// Original array 
  
var obj1 = (['a', 'g', 'h', 
    'b', 'c', 'd', 'e', 'f']);
  
// Use of _.zipObjectDeep() 
// method
  
let gfg = _.zipObjectDeep(obj1, 
        [1, 2, 3, 4, 5, 6, 7]);
  
// Printing the output 
console.log(gfg);


Output:

{ a: 1, g: 2, h: 3, b: 4, c: 5, d: 6, e: 7, f: undefined }

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!
RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6864 POSTS0 COMMENTS
Umr Jansen
6852 POSTS0 COMMENTS