Getters are used to access the value of an object's property, while functions are used to perform a specific action or computation.
Advantages of using getters:
Encapsulation: Getters allow you to hide the implementation details of a class from the user, making it easier to modify the underlying implementation without affecting the code that uses the class.
Consistency: Getters provide a consistent interface for accessing the properties of an object, regardless of the implementation details.
Computed properties: Getters allow you to compute a value based on the state of an object, which can be useful for creating computed properties.
Kumar Raj
Great article. I'm sorry to trouble you but Please tell me why does the only difference of parentheses, during calling the function or getter method, matter so much? What are the advantages of using these over functions?