I found the following in the Mozilla-documentation:
If undefined, a function, or an XML value is encountered during conversion it is either omitted (when it is found in an object) or censored to null (when it is found in an array).
My question is: Do all modern browsers behave in this way? Can I rely on stringify() to ignore my object methods?
The complete algorithm for
JSON.stringifycan be found in the specification: https://es5.github.io/x15.12.html#x15.12.3.Basically, for every value that is not an object,
null, a boolean, a number or a string, the serialisation function returnsundefinedandundefinedvalues are not rendered.That does not necessarily guarantee that every browser implements it this way, but the only browser getting out of line is normally IE. Every other browser is very close to the specification.