TLDR Web Dev · QUICK LINKS

SHALLOW CLONES VERSUS STRUCTURED CLONES

philna.sh5 min read

Summary from the TLDR Web Dev newsletter

When creating deep copies of nested JavaScript objects, using `structuredClone` instead of shallow cloning methods like the spread operator (`...`) prevents unexpected state mutations by verifying that all nested objects and arrays are duplicated, not just referenced.