Object Property Access
Multiple Choice Easy
Question
Which is valid for accessing an object property with a space in its name?
Hint
Dot notation requires valid identifier names (no spaces).
Explanation
Bracket notation obj["my property"] works because it accepts any string as the key. Dot notation obj.my property is a syntax error because property names after the dot must be valid identifiers, which cannot contain spaces. Bracket notation is also needed for dynamic keys.
Related Resources
Related Lessons
- Objects
Learn how objects work.
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.