Home > @infiniteobjects/core-library-web > Obj > clone
Return a deep copy of the specified object.
Signature:
static clone<T = ObjectLike>(object: T, depth?: number): T;
Parameter | Type | Description |
---|---|---|
object | T | The original object to copy from |
depth | number | (Optional) An optional depth to prevent recursion. Default: 20. |
Returns:
T
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.