DEV Community

Discussion on: Using Static Keyword in JavaScript

 
stemmlerjs profile image
Khalil Stemmler

The getter is just another syntactic-sugar to reach into objects. It's equivalent to using the dot notation like person.name but it provides the ability for you to:

  • watch when objects are being accessed (in general, this is how Vue.js detects changes)
  • dynamically create return objects

It enables you to do both of those without changing the syntax.

Thread Thread
 
devhammed profile image
Hammed Oyedele

Getters are usually used to create dynamic properties because it is a function you can write logic e.g you can read value of a property from a file or from database.