JavaScript Object-Oriented JavaScript Getters and Setters Getters

Jake Smith
Jake Smith
Full Stack JavaScript Techdegree Student 7,154 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
173,506 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.