OutputNot attempted
What JSON round-tripping loses
const src = { d: new Date(0), u: undefined, f() {}, n: NaN, s: new Set([1]) };const copy = JSON.parse(JSON.stringify(src));console.log(typeof copy.d, 'u' in copy, 'f' in copy, copy.n, copy.s);Spaces and quote style don’t matter · write a thrown error as TypeError
Ctrl Enter
Show answer & explanation
The expected output comes from actually running the snippet; opening this shows it next to the explanation.
JSON: Date → ISO string, undefined and functions are dropped, NaN/Infinity → null, Set/Map → {}. structuredClone keeps Date/Map/Set but throws on functions.