JavaScript · Junior · Question 72 of 75
What happens with JSON.parse("{ name: 'Ann' }")?
- ✓Correct answer: It throws a
SyntaxError- JSON requires double-quoted keys and strings - 2It returns
{ name: 'Ann' } - 3It returns
null
Explanation
JSON is stricter than JS object literals: no single quotes, no trailing commas, no comments. Wrap parsing of untrusted data in try/catch.