Predict Nested Object Access
Predict Output Easy
Question
What does this code print?
Code
const data = {
user: {
address: {
city: "Portland"
}
}
};
console.log(data.user.address.city);
Hint
Chain dot notation to access nested properties.
Explanation
Chained dot notation accesses nested properties: data.user gives the user object, .address gives the address object, and .city gives "Portland". Each step drills one level deeper into the nested structure.
Related Resources
Related Lessons
- JavaScript Objects
Learn about nested objects.
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.