Recursively merges properties of the source object into the target object. Nested plain objects are merged, while arrays and primitive values are replaced.
source
target
The target object to merge into.
The source object whose properties will be merged.
A new object containing merged properties from both target and source.
const obj1 = { a: 1, b: { x: 10 } };const obj2 = { b: { y: 20 }, c: 3 };const merged = deepMerge(obj1, obj2);console.log(merged); // { a: 1, b: { x: 10, y: 20 }, c: 3 } Copy
const obj1 = { a: 1, b: { x: 10 } };const obj2 = { b: { y: 20 }, c: 3 };const merged = deepMerge(obj1, obj2);console.log(merged); // { a: 1, b: { x: 10, y: 20 }, c: 3 }
1.1.0
Recursively merges properties of the
source
object into thetarget
object. Nested plain objects are merged, while arrays and primitive values are replaced.