merge es-toolkit
Deeply merges the source object into the target object, modifying the target object.
Usage
merge(target, source)
Use merge when you want to deeply merge two objects. Nested objects and arrays are also merged recursively. Unlike toMerged, this function modifies the original target object.
undefined values do not overwrite existing values.
Parameters
targetT extends Record<PropertyKey, any>required
The target object to merge the source object into. This object is modified.
sourceS extends Record<PropertyKey, any>required
The source object to merge into the target object.
Returns
Returns the target object with the source object merged in.
Examples
Try It
::: sandpack
:::
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.