🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///

Untitled Lesson

Total XP: 0|💻 backend XP: 0

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Select an unlocked node to view details root

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Common Pitfalls & Errors

The Error //

Using JSON.parse(JSON.stringify(obj)) to deep clone an object containing Dates, Maps, or Sets

// Wrong: Date becomes a string, Map becomes {} const copy = JSON.parse(JSON.stringify({ date: new Date(), m: new Map() })); // Correct const copy = structuredClone({ date: new Date(), m: new Map() });

The Solution //

JSON serialization silently converts Dates to ISO strings, drops undefined values and functions entirely, and cannot represent Map or Set at all — producing a "clone" with a different shape than the original. structuredClone() is the standards-based deep-clone that correctly preserves all of these types.

The Error //

Manually parsing query strings with string.split("&") and split("=") instead of URLSearchParams

// Wrong: breaks on encoded characters and edge cases const page = queryString.split("&").find(p => p.startsWith("page=")).split("=")[1]; // Correct const url = new URL(fullUrl); const page = url.searchParams.get("page");

The Solution //

Manual query-string parsing breaks on edge cases the spec already handles correctly — URL-encoded characters, repeated keys, and empty values. The built-in URL and URLSearchParams classes handle encoding/decoding and edge cases correctly with far less code and no custom regex to maintain.

Continue Learning