Predict Object Access Output
Predict Output Easy
Question
What does this code print?
Code
const person = { name: "Ada", age: 36 };
console.log(person.name);
console.log(person["age"]);
Hint
Both dot notation and bracket notation access properties.
Explanation
person.name uses dot notation to get "Ada". person["age"] uses bracket notation to get 36. Both notations access the same property. The output is: Ada (first line) and 36 (second line).
Related Resources
Related Lessons
- Objects
Learn how objects group related data with keys and values.
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.