Besides storing data in properties, objects can also perform functions on themselves and other objects. Recall that a function is a named group of one or more programming statements. A method is a function that is called from within an object.
For example, a method could be used to manipulate the properties of an object. Some methods simply perform their actions when they are called, while other methods require more information before they can be processed. A method can accept any number of required and optional input arguments.
To add a method to an object, name the method and then assign the method to a function