stack

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

Obj.clone() method

Return a deep copy of the specified object.

Signature:

static clone<T = ObjectLike>(object: T, depth?: number): T;

Parameters

Parameter Type Description
object T The original object to copy from
depth number (Optional) An optional depth to prevent recursion. Default: 20.

Returns:

T

Remarks

This returns a new object with all elements copied recursively. Special handling is provided for Date objects and Array objects. Maps, Sets, Functions and other complex types are not supported and copied by reference.