Methods in Objects
An object contains properties, where the property value can either be a value or a function. In case the property is a function, it is referred to as an object method.
Let’s consider a scenario where you have an object named
employee with the properties
designation. Now you are required to write an object method
display() that returns the
designation of that employee. The first approach that comes to mind is something like this: