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

Peter May
Peter May
16,376 Points

I practiced\ and find this confusing. I slashed out //the previous logs and tried running just the ernie[prop]. Nothing?

I practiced\ and find this confusing. I slashed out //the previous logs and tried running just the ernie[prop]. Nothing? for us newbs this is confusing. How would you call this with a new var and how to you assign key pairs to an outside var. would love more details. Thank you in advance. (any articles also appreciated.)

1 Answer

var prop = 'breed'
ernie[prop]

is the same as

ernie['breed']

which is also the same as

ernie.breed