Reasons to use Getters and Setters
- The syntax for properties and methods are equal.
- Used for doing things behind the scenes.
- They can secure better data quality.
- The syntax of this is simpler.
JavaScript Object Accessors
There are two keywords that define the accessors functions: a getter and a setter for the fullName property. When the property is accessed, the return value from the getter is used. When a value is set, the setter is called and passed the value that was set.