Merge Objects
Deeply merges two or more objects using an efficient key-value storage and conflict resolution strategy.
mergeObjects
The mergeObjects function deeply merges two or more objects recursively. Duplicate keys are resolved using a last-in-wins strategy.
Function Signature
function mergeObjects<T extends GenericObject>(...objects: T[]): MergeAll<T>Parameters
...objects(T[]): The objects to merge (variadic arguments).
Return Value
MergeAll<T>: A new object containing the merged results.
Example Usage
playground.ts
Notes
- Arrays: Arrays are treated as terminal/primitive values and are overwritten rather than recursively merged.
- Returns a new object without mutating any of the input objects.
Comparison
mergeObjects: Outputs a deeply nested merged object structure.- mergeAndFlattenObjects: Outputs a single-level flat object with dot-separated keys.
Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)
