How to define methods for an Object in JavaScript?

JavascriptWeb DevelopmentFront End Technology

Methods are the functions that let the object do something or let something is 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 this keyword.

Methods are used 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. 

Here’s an example showing how to use the write() method of the document object to write any content on the document.

document.write("This is test");
Published on 03-Feb-2018 11:17:39