Bayu prints a customer’s record in the passbook as JSON and reads it back: undefined, Date, NaN, Map, BigInt, a record pointing at itself, which print whole…
Why it matters
Every time you send data to an API, save it to localStorage, or "deep copy" with JSON.parse(JSON.stringify(x)), these traps wait: fields vanish silently, dates change type, or the app stops on a loop or a BigInt.
The key idea
JSON knows six kinds; the rest is dropped, changed, or throws
Common mistakes
"Deep copying" with JSON.parse(JSON.stringify(x)) silently damages dataundefined and functions are dropped, a Date becomes text, loops and BigInts throw. Use structuredClone(x).
Some fields vanish from the print without a warningundefined, function and symbol values are dropped. Use null for a field that must stay, and check the print.
Sending a BigInt through JSON.stringify throws a TypeError Turn it into text first (String(id)), or use a replacer: (k, v) => typeof v === 'bigint' ? String(v) : v.
Try it in this playground
Print a record with an undefined or function drawer Its drawer is dropped without a warning, the key gone from the print.
Print a Date, then see what comes back It comes back as text, not a Date.
Jam the printer: a BigInt or a loop JSON.stringify throws a TypeError.
Use the replacer "BigInt to text" A big number prints as whole text.