InterviewSolution
| 1. |
What Is Object Methods? |
|
Answer» Methods are the functions that let the object do something or let something be done to it. There is a small difference between a FUNCTION and a method – at a function is a standalone unit of statements and a method is ATTACHED to an object and can be referenced by the this keyword. Methods are USEFUL for everything from displaying the contents of the object to the screen to performing complex mathematical operations on a group of local PROPERTIES and parameters. For EXAMPLE − Following is a simple example to show how to use the write() method of document object to write any content on the document. document.write("This is test"); Methods are the functions that let the object do something or let something be done to it. There is a small difference between a function and a method – at a function is a standalone unit of statements and a method is attached to an object and can be referenced by the this keyword. Methods are useful for everything from displaying the contents of the object to the screen to performing complex mathematical operations on a group of local properties and parameters. For example − Following is a simple example to show how to use the write() method of document object to write any content on the document. document.write("This is test"); |
|