6.2 Objects and methods
Objects are a natural way of thinking about the world and of writing scripts that manipulate XHTML documents. Java Script uses objects to perform many tasks and therefore referred to as and ovject-based programming language.
It facilitates objects to be defined ad used in the documents. All objects in the real world have attributes such as size, shape color, weight and the like; and they all exhibit behaviours, for example a ball rolls, bounces, inflates and deflates, a baby cries, sleeps, crawls and walks. Humans learn about objects by studying their attributes and observing their behaviors. Objects encapsulate data(properties) and methods. A java script object is a composition of its properties and method. For example a student has name, number, mark1, mark2, as its properties and total calculation and average are methods.
Java script handles the HTML documents and the related objects such as windows, forms and screen in a specific hierarchy. This hierarchy is called the Document Object Model (DOM) which is directly related to the browsers. The properties of the object covered in the DOM get their values supplied by the browser.
The following table shows the most commonly used Java Script objects.
Table 6.1. Hierarchy of Objects their Properties and Methods.