Can I stringify functions and `undefined` values using `JSON.stringify()`?

Question

Grade: Education Subject: Support
Can I stringify functions and `undefined` values using `JSON.stringify()`?
Asked by:
74 Viewed 74 Answers

Answer (74)

Best Answer
(295)
No, functions and `undefined` values are automatically omitted when using `JSON.stringify()`. If a function is encountered as a property value, it's simply not included in the resulting JSON string. `undefined` values are also ignored. You can control this behavior with the replacer function.