structuredClone Playground

Copy a customer’s record four ways, spread, Object.assign, the JSON trick and structuredClone, then change the copy: does the original change too, and what…

Why it matters

One of the sneakiest sources of state bugs: you think you made a copy, but the objects inside are still shared. In React especially, mutating a spread copy’s insides silently damages the old state. Knowing shallow from deep means safe state updates.

The key idea

Spread is SHALLOW: the boxes inside are shared, not copied

Common mistakes

Try it in this playground