Home > doofinder > merge

merge() function

Merge multiple objects into one.

Signature:

export declare function merge(...objects: Record<string, any>[]): Record<string, any>;

Parameters

Parameter Type Description
objects Record<string, any>[] An undetermined number of objects to merge.

Returns:

Record<string, any>

An object resulting of merging the provided objects.

Remarks

Heavily based on https://www.npmjs.com/package/extend.

While extend() fully extends objects, this version only touches own properties and not inherited ones. This is intended to extend only option objects, not functions used as constructors or anything like that.

Why? Try to use PrototypeJS in the same page as Doofinder and use extend instead to have some fun debugging.

Works the same as extend, but merge is always “deep”

__WARNING:__ Be careful with arrays of objects, you can end having duplicates.