🧬 Deep clone showdown

Build a nested object with a Date, a Set, a Map, and (optionally) a circular reference. Then watch {...obj}, JSON.parse(JSON.stringify(obj)), and structuredClone(obj) handle the exact same object three different ways.

1 Build the object

2 Clone it three ways
const shallow    = { ...obj }; const roundTripped = JSON.parse(JSON.stringify(obj)); const trueClone    = structuredClone(obj);
Loading…

Each clone is made once, right when you pick a preset. "Mutate the nested value" only changes the original object afterwards β€” the checklist below reveals which copies quietly followed along.