Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Object-Oriented JavaScript Object Basics Dot Notation & Bracket Notation

Thomas Chappel
Thomas Chappel
6,342 Points

Property keys can have spaces inside them?

In this lesson it is said that 'bracket notation allows us to access or create properties that have spaces inside the property key'. This goes against what I learnt so far, I thought that property keys should follow the same rules for naming variables, which means no spaces inside!

Can someone give me an explanation?

1 Answer

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,028 Points

That's one of the differences between dot and bracket notation. The video encourages you to think of bracket notation as the style that's used less frequently as it's more difficult to read but has more flexibility. It's totally up to you which style you prefer but it's good to know both. :-)