JavaScript › JSON & Data Serialization
What values does JSON.stringify() silently drop or convert, and why does this matter?
IntermediateAnswer
Functions, undefined, and Symbols are omitted entirely from objects (or converted to null inside arrays); Dates are converted to ISO strings; NaN and Infinity become null — meaning a round trip through JSON can silently lose or alter data types you didn't expect.
JSON.stringify({ fn: () => {}, val: undefined, date: new Date(), num: NaN });
// '{"date":"2026-08-08T00:00:00.000Z","num":null}'
// fn and val were dropped entirelyReal-world example A bug where a Date field silently becomes a plain string after being sent through an API, breaking date methods on the receiving end.