← Back to Coding Challenges
● CLIENT SANDBOX ISOLATED
HARD
#recursion#weakmap#javascript
Deep Clone with Circular References
Implement a `deepClone` function that creates a deep copy of an object or array.
It must handle:
- Primitive values
- Nested objects and arrays
- Dates
- Circular references without causing infinite recursion.
CONSTRAINTS
Do not use JSON.parse(JSON.stringify(x)) or structuredClone.
TEST SPECIFICATIONS (2)
INPUT: [{"a":1,"b":{"c":2}}]
EXPECTED: {"a":1,"b":{"c":2}}
INPUT: [[1,[2,3]]]
EXPECTED: [1,[2,3]]
solution.js
INITIALIZING MONACO EDITOR...