Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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
MOD
Jonathan Grieve
Treehouse Moderator 91,253 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. :-)