Wednesday, March 12, 2008

Objects And Object Hierarchy

What is Objects?
In order to understand what it means for JavaScript to be object-based, we need to look at objects and how they work. , objects are a way of organizing information, along with the methods for manipulating and using that information.
Objects provide a way to define specific pieces of data related to the item in question; these pieces are known as properties. In addition, these are supplemented by tasks that can be performed on or with that information, known as methods. Together properties and methods make up objects.
Because of the general nature of objects, specific instances can be created for each case where they are needed. For instance, a car object could then have several instances for Toyotas, Fords, and Volkswagens
Working with Objects in JavaScript
JavaScript includes both built-in objects to work with elements of the currently loaded HTML document, as well as performing other useful tasks, such as mathematical calculations. It also offers the programmers the chance to create their own objects.
Built-In Objects :- JavaScript offers a set of built-in objects that provide information about the currently loaded Web page and its contents, as well as the current session of Navigator. In addition, these objects provide methods for working with their properties.
The Navigator Object Hierarchy: -Most of the built-in objects in JavaScript are part of the Navigator Object Hierarchy. The Navigator Object Hierarchy is built from a single base object called the window object, as illustrated in the following outline.
[1] Window:-The window object provides methods and properties for dealing with the actual Navigator window, including objects for each frame.
[2] Location:-The location object provides properties and methods for working with the currently opened URL.
[3] History:-The history object provides information about the history list and enables limited interaction with the list.
[4] Document:-The document object is one of the most heavily used objects in the hierarchy. It contains objects, properties, and methods for working with document elements including forms, links and anchors.
[5] Forms [6] Anchors
In addition to the objects in the Navigator Object Hierarchy, JavaScript provides several objects that are not related to the current windows or loaded documents.
String: - The string object enables programs to work with and manipulate strings of text, including extracting substrings and converting text to upper or lower case characters.
Math: - The Math object provides methods to perform trigonometric functions, such as sine and tangent, as well as general mathematical functions, such as square roots.
Date: - With the Date object, programs can work with the current date or create instances for specific dates. The object includes methods for calculating the difference between two dates and working with times.

No comments: