JSON.parse(JSON.stringify()) vs structuredClone: What Survives the Copy
I copied objects with JSON.parse(JSON.stringify(obj)) for years. It works right up until the object holds something JSON has no idea about. I ran a test on Node.js 22 with four values that break the trick: const original = { date : new Date ( "2026-01-01T00:00:00Z" ) , map : new Map ( [ [ "a" , 1 ]…
Read the full story at DEV Community — AI ↗
Timeline · 1 report
- 2026-12-05 03:39 · DEV Community — AI
JSON.parse(JSON.stringify()) vs structuredClone: What Survives the Copy