deepmerge
The deepmerge
function recursively merges two objects, combining their
properties and deeply merging nested objects. It can optionally clone
objects during the merge to avoid mutating the original input. This is
useful when merging configuration objects, state trees, or any deeply
nested structures.
- @param
target
- The target object that will receive properties from the source object. - @param
source
- The source object from which properties will be copied and merged into the target. - @param
options
[object Object],[object Object],[object Object] - @returns The merged object, which is a combination of properties from both the target and source objects.
Example
deepmerge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }