stack

Home > @infiniteobjects/core-library-web > Obj > merge

Obj.merge() method

Creates a new object by deeply copying the properties of object2 in object1.

Signature:

static merge<T1 = ObjectLike, T2 = ObjectLike>(object1: T1, object2: T2, depth?: number): Merge<T1, T2>;

Parameters

Parameter Type Description
object1 T1 Base object
object2 T2 Extending object
depth number (Optional) An optional depth to prevent recursion. Default: 20.

Returns:

Merge<T1, T2>

Remarks

For array properties, if the property is present on both objects, the result will have the value of the second object. Meaning, the original array will be discarded and replaced by the new one.