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 Getters and Setters Getters

Jake Smith
seal-mask
.a{fill-rule:evenodd;}techdegree
Jake Smith
Data Analysis Techdegree Student 15,921 Points

Just need clarification on getters

I just want to be absolutely sure I understand the use case for getters.

Getters are 1) properties (as opposed to methods) and 2) only used for information that isn't meant to be static in your class instances?

Thanks in advance :)

1 Answer

Steven Parker
Steven Parker
231,268 Points

Technically, a "get" is a property accessor, but it is invoked by just using the property which is different from invoking a method.

And it would certainly not be typical to use one with static information, but it might be done for things like dealing with access level restrictions in the static data.