
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
deep-extend
Advanced tools
Recursive object extending.
$ npm install deep-extend
var deepExtend = require('deep-extend');
var obj1 = {
a: 1,
b: 2,
d: {
a: 1,
b: [],
c: { test1: 123, test2: 321 }
},
f: 5,
g: 123,
i: 321,
j: [1, 2]
};
var obj2 = {
b: 3,
c: 5,
d: {
b: { first: 'one', second: 'two' },
c: { test2: 222 }
},
e: { one: 1, two: 2 },
f: [],
g: (void 0),
h: /abc/g,
i: null,
j: [3, 4]
};
deepExtend(obj1, obj2);
console.log(obj1);
/*
{ a: 1,
b: 3,
d:
{ a: 1,
b: { first: 'one', second: 'two' },
c: { test1: 123, test2: 222 } },
f: [],
g: undefined,
c: 5,
e: { one: 1, two: 2 },
h: /abc/g,
i: null,
j: [3, 4] }
*/
$ npm test
Please, report about issues here.
Lodash provides a method called merge which can recursively merge own and inherited enumerable string keyed properties of source objects into the destination object. It's similar to deep-extend but comes as part of the larger lodash utility library, which offers a wide range of functions for different purposes.
The extend package is another utility that can merge objects but does not offer deep merge capabilities by default. It is less powerful for deep object merging compared to deep-extend but can be used for shallow merges.
Merge-deep is similar to deep-extend as it allows for deep merging of objects. It recursively merges own and inherited enumerable properties of source objects into the destination object, similar to deep-extend, and is a good alternative if deep-extend is not suitable for some reason.
FAQs
Recursive object extending
The npm package deep-extend receives a total of 32,590,708 weekly downloads. As such, deep-extend popularity was classified as popular.
We found that deep-extend demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.