Implement a function deepClone(value) that performs a deep copy of any JavaScript value, including objects and arrays. The function should also handle circular references to avoid infinite loops.
The function should:
Examples
const obj = { a: 1, b: { c: 2 } }; const clone = deepClone(obj); clone.b.c = 3; console.log(obj.b.c); // 2 const circular = { }; circular.self = circular; const cloneCircular = deepClone(circular); console.log(cloneCircular.self === cloneCircular); // true
JavaScript Function
No test results yet
Click "Run" to execute tests