JavaScript · Junior · Question 31 of 75
What does JSON.stringify({ a: 1, b: undefined, c: () => 1 }) return?
- ✓Correct answer:
'{"a":1}' - 2
'{"a":1,"b":null,"c":null}' - 3
TypeError
Explanation
Properties whose values are undefined, functions or symbols are skipped (in arrays they become null). Date becomes a string, Map and Set become {}. Circular references throw an error.