cloneDeep
cloneDeep<
T>(params):T
Defined in: objects/clone-deep/index.ts:78
Creates a deep clone of a value.
Handles plain objects, arrays, dates, regexes, maps, sets, typed arrays, array buffers, errors, and circular references. Functions are copied by reference.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”params
Section titled “params”CloneDeepParams<T>
The parameters object
Returns
Section titled “Returns”T
A deep clone of the value
Example
Section titled “Example”const original = { a: { b: [1, 2] }, date: new Date() };const cloned = cloneDeep({ value: original });
cloned.a.b.push(3);original.a.b; // [1, 2] — unaffectedKeywords
Section titled “Keywords”deep clone, deep copy, clone object, copy object, structuredClone alternative
structuredClone - native alternative that fails on classes, functions, and DOM nodes