JSON Undefined Handling
Multiple Choice Medium
Question
What happens to undefined properties in JSON.stringify?
Hint
JSON does not support undefined.
Explanation
JSON.stringify omits properties with undefined values entirely. Properties with null values are preserved as null. This is because undefined is not a valid JSON value. For example, JSON.stringify({a: undefined, b: null}) gives '{"b":null}'. This behavior can cause issues when round-tripping data through JSON.
Related Resources
Related Lessons
- Data Types
Learn JS data types.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.