GuobaGuoba Utils

deepClone

@guoba-ai/utils / object / deepClone

Function: deepClone()

function deepClone<T>(obj): T;

Defined in: object.ts:45

Deep clone a value using structuredClone.

Type Parameters

T

T

Parameters

obj

T

The value to clone

Returns

T

A deep copy of the value

Example

const original = { a: { b: 1 } }
const copy = deepClone(original)
copy.a.b = 2
original.a.b // still 1

On this page