Using JS Objects with properties & Methods:
In the example your just saw, I displayed an alert box using a JS alert() method of the window object. It's purpose is to display pop-up boxes with some text and a button labeled "OK".
An object contain functions, which are known as methods when part of an object. methods are called using the basic syntax: objectName.methodName(). Any arguments required for the method are passed between the parentheses, just like a normal function call.
For example, the window object possesses a method
which simply displays an alert window.
Since it's not necessary to specify the window object we can leave it out from the code. Thus, the following code will function equally well as the one above.
alert("This is an alert method in the for of a popup box");
In JS there are methods are available to:
Tryit: Create an window alert method in the body section of an html document. Also, manipulate the document object using document methods. See table of methods for the document object.
Here are a few types of commands that methods are useful for.