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 DOM Scripting By Example Improving the Application Code Refactor 2: Readable Branching Logic

Marcus Schumacher
Marcus Schumacher
16,616 Points

Where to learn more about these kinds of JS object abilities?

At 3:50 in the video, what is going on here? Where can I read or learn more about this? I didn't know that objects in JS can have properties that are functions themselves. What would you call this kind of function declaration in an object?

At 6:48, how does this type of accessing work? Does it treat the object like an array? Whatever is in the brackets is selected from the object? What is this called? How could I learn more? Thanks. This is new stuff for me :)

1 Answer

Steven Parker
Steven Parker
231,271 Points

An object property that is also a function is known as a "method".

The access technique you are referring to is called "bracket notation". It's an alternative to the more commonly used "dot notation".

You might enjoy exploring objects further in the recently revamped course Object-Oriented JavaScript.