Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Recursively traverse the object, creating new arrays and objects at each level and cloning their contents. Use a WeakMap to track already-cloned references, which handles circular references by returning the previously created clone instead of recursing infinitely.
The WeakMap acts as a visited set that maps original objects to their clones, breaking circular reference cycles while ensuring each object is only cloned once.
Updated Feb 2026