Skip to content

clone

clone<T>(value, options?): T

Defined in: packages/core/src/object/clone.ts:149

Clone a value.

By default the copy is faithful: it keeps the original’s prototype, its symbol-keyed and non-enumerable properties, and its property attributes. Pass recursive to copy nested values too.

Time complexity: O(1) in the size of the tree for a shallow clone, O(n) over every reachable value for a recursive one.

T

T

The value to clone

CloneOptions

Clone options

T

The cloned value

If a value cannot be copied and unsupported is "throw", or if the transfer list is invalid or not fully reached.