Predict JSON Parsing Output
Predict OutputEasy
Question
What does this JavaScript code print after parsing a JSON string?
Code
const data = JSON.parse('{"age": 25}');
console.log(data.age);
Hint
JSON.parse converts a JSON string into a JavaScript object.
Explanation
JSON.parse takes a JSON-formatted string and returns a JavaScript object. The string {"age": 25} becomes an object with an age property of 25. Accessing data.age gives 25, which is what console.log prints.
Related Resources
Related Lessons
- JSON
Learn how to parse and stringify JSON.
Related Tools
- JSON Formatter
Practice with JSON data.
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.