Deep cloning objects? JSON.parse(JSON.stringify()) fails on dates, functions, undefined.
// ❌ Old way (loses dates, functions) const copy = JSON.parse(JSON.stringify(original)); // ✅ New way (preserves everything) const copy = structuredClone(original); // Works with: // - Nested objects // - Arrays // - Dates // - Maps, Sets // - RegExp // - ArrayBuffer
Performance: Faster than JSON method.
Browser Support: 93% (Chrome 98+, Firefox 94+, Safari 15.4+)
