Deep clones Objects, Arrays, Maps and Sets with circular reference protection
The value to clone
WeakMap to track circular references (internal use)
Cloned value
const obj = { a: 1, b: { c: 2 } };obj.circular = obj; // Create circular referenceconst cloned = clone(obj); // Works without stack overflow Copy
const obj = { a: 1, b: { c: 2 } };obj.circular = obj; // Create circular referenceconst cloned = clone(obj); // Works without stack overflow
Deep clones Objects, Arrays, Maps and Sets with circular reference protection