A new deeply-merged object.
// Basic merge
const a = { name: 'Alice', meta: { visits: 1 } };
const b = { meta: { lastSeen: new Date() }, age: 30 };
const merged = objectDeepMerge(a, b);
// { name: 'Alice', meta: { visits: 1, lastSeen: ... }, age: 30 }
// Multiple objects
const merged = objectDeepMerge({ a: 1 }, { b: 2 }, { c: 3 });
// { a: 1, b: 2, c: 3 }
// Custom options via withOptions
const merged = objectDeepMerge.withOptions({ arrayMerge: 'concat' })(
{ tags: ['js'] },
{ tags: ['css'] }
);
// { tags: ['js', 'css'] }
{ arrayMerge: 'concat' } to
concatenate instead.Date, RegExp, Map, Set, Error, ArrayBuffer,
SharedArrayBuffer, typed arrays, etc.) are treated as atomic — the
right-hand value overwrites the left.null is treated as a primitive, not an object. A null on the
right will overwrite any left-hand value.objectDeepMerge.withOptions({ maxDepth: … }).Deeply merge two or more objects into a new object.
Merging is left-to-right: each subsequent object's properties take
precedence over the previous ones. For plain objects, properties are
recursively merged. Primitives, arrays (by default), and special built-in
types (Date, RegExp, Map, Set, etc.) are overwritten by the
right-hand value.
Use objectDeepMerge.withOptions when you need non-default merging behaviour (e.g. array concatenation or a custom depth limit).
Immutability: Inputs are never modified. Every call returns a fresh object graph.
Circular references: Detected and handled safely via internal WeakMap tracking — no infinite loops.
A new deeply-merged object.
// Basic merge
const a = { name: 'Alice', meta: { visits: 1 } };
const b = { meta: { lastSeen: new Date() }, age: 30 };
const merged = objectDeepMerge(a, b);
// { name: 'Alice', meta: { visits: 1, lastSeen: ... }, age: 30 }
// Multiple objects
const merged = objectDeepMerge({ a: 1 }, { b: 2 }, { c: 3 });
// { a: 1, b: 2, c: 3 }
// Custom options via withOptions
const merged = objectDeepMerge.withOptions({ arrayMerge: 'concat' })(
{ tags: ['js'] },
{ tags: ['css'] }
);
// { tags: ['js', 'css'] }
{ arrayMerge: 'concat' } to
concatenate instead.Date, RegExp, Map, Set, Error, ArrayBuffer,
SharedArrayBuffer, typed arrays, etc.) are treated as atomic — the
right-hand value overwrites the left.null is treated as a primitive, not an object. A null on the
right will overwrite any left-hand value.objectDeepMerge.withOptions({ maxDepth: … }).Deeply merge two or more objects into a new object.
Merging is left-to-right: each subsequent object's properties take
precedence over the previous ones. For plain objects, properties are
recursively merged. Primitives, arrays (by default), and special built-in
types (Date, RegExp, Map, Set, etc.) are overwritten by the
right-hand value.
Use objectDeepMerge.withOptions when you need non-default merging behaviour (e.g. array concatenation or a custom depth limit).
Immutability: Inputs are never modified. Every call returns a fresh object graph.
Circular references: Detected and handled safely via internal WeakMap tracking — no infinite loops.
A new deeply-merged object.
// Basic merge
const a = { name: 'Alice', meta: { visits: 1 } };
const b = { meta: { lastSeen: new Date() }, age: 30 };
const merged = objectDeepMerge(a, b);
// { name: 'Alice', meta: { visits: 1, lastSeen: ... }, age: 30 }
// Multiple objects
const merged = objectDeepMerge({ a: 1 }, { b: 2 }, { c: 3 });
// { a: 1, b: 2, c: 3 }
// Custom options via withOptions
const merged = objectDeepMerge.withOptions({ arrayMerge: 'concat' })(
{ tags: ['js'] },
{ tags: ['css'] }
);
// { tags: ['js', 'css'] }
{ arrayMerge: 'concat' } to
concatenate instead.Date, RegExp, Map, Set, Error, ArrayBuffer,
SharedArrayBuffer, typed arrays, etc.) are treated as atomic — the
right-hand value overwrites the left.null is treated as a primitive, not an object. A null on the
right will overwrite any left-hand value.objectDeepMerge.withOptions({ maxDepth: … }).Deeply merge two or more objects into a new object.
Merging is left-to-right: each subsequent object's properties take
precedence over the previous ones. For plain objects, properties are
recursively merged. Primitives, arrays (by default), and special built-in
types (Date, RegExp, Map, Set, etc.) are overwritten by the
right-hand value.
Use objectDeepMerge.withOptions when you need non-default merging behaviour (e.g. array concatenation or a custom depth limit).
Immutability: Inputs are never modified. Every call returns a fresh object graph.
Circular references: Detected and handled safely via internal WeakMap tracking — no infinite loops.
A new deeply-merged object.
// Basic merge
const a = { name: 'Alice', meta: { visits: 1 } };
const b = { meta: { lastSeen: new Date() }, age: 30 };
const merged = objectDeepMerge(a, b);
// { name: 'Alice', meta: { visits: 1, lastSeen: ... }, age: 30 }
// Multiple objects
const merged = objectDeepMerge({ a: 1 }, { b: 2 }, { c: 3 });
// { a: 1, b: 2, c: 3 }
// Custom options via withOptions
const merged = objectDeepMerge.withOptions({ arrayMerge: 'concat' })(
{ tags: ['js'] },
{ tags: ['css'] }
);
// { tags: ['js', 'css'] }
{ arrayMerge: 'concat' } to
concatenate instead.Date, RegExp, Map, Set, Error, ArrayBuffer,
SharedArrayBuffer, typed arrays, etc.) are treated as atomic — the
right-hand value overwrites the left.null is treated as a primitive, not an object. A null on the
right will overwrite any left-hand value.objectDeepMerge.withOptions({ maxDepth: … }).Deeply merge two or more objects into a new object.
Merging is left-to-right: each subsequent object's properties take
precedence over the previous ones. For plain objects, properties are
recursively merged. Primitives, arrays (by default), and special built-in
types (Date, RegExp, Map, Set, etc.) are overwritten by the
right-hand value.
Use objectDeepMerge.withOptions when you need non-default merging behaviour (e.g. array concatenation or a custom depth limit).
Immutability: Inputs are never modified. Every call returns a fresh object graph.
Circular references: Detected and handled safely via internal WeakMap tracking — no infinite loops.
The tuple of types to merge.
Two or more objects to merge.
A new deeply-merged object.
// Basic merge
const a = { name: 'Alice', meta: { visits: 1 } };
const b = { meta: { lastSeen: new Date() }, age: 30 };
const merged = objectDeepMerge(a, b);
// { name: 'Alice', meta: { visits: 1, lastSeen: ... }, age: 30 }
// Multiple objects
const merged = objectDeepMerge({ a: 1 }, { b: 2 }, { c: 3 });
// { a: 1, b: 2, c: 3 }
// Custom options via withOptions
const merged = objectDeepMerge.withOptions({ arrayMerge: 'concat' })(
{ tags: ['js'] },
{ tags: ['css'] }
);
// { tags: ['js', 'css'] }
{ arrayMerge: 'concat' } to
concatenate instead.Date, RegExp, Map, Set, Error, ArrayBuffer,
SharedArrayBuffer, typed arrays, etc.) are treated as atomic — the
right-hand value overwrites the left.null is treated as a primitive, not an object. A null on the
right will overwrite any left-hand value.objectDeepMerge.withOptions({ maxDepth: … }).
Deeply merge two or more objects into a new object.
Merging is left-to-right: each subsequent object's properties take precedence over the previous ones. For plain objects, properties are recursively merged. Primitives, arrays (by default), and special built-in types (
Date,RegExp,Map,Set, etc.) are overwritten by the right-hand value.Use objectDeepMerge.withOptions when you need non-default merging behaviour (e.g. array concatenation or a custom depth limit).
Immutability: Inputs are never modified. Every call returns a fresh object graph.
Circular references: Detected and handled safely via internal WeakMap tracking — no infinite loops.