JavaScript Objects

We can begin to look at the actual Objects that JavaScript itself provides. These Objects can be put into the following three categories:

Built-in Objects include String Objects, the Date Object, and the Math Object. They are referred to as Built-in because they really do not have anything to do with Web pages, HTML, URLs, the current browser environment, or anything visual. HTML objects, in turn, are directly associated with elements of Web pages. Every Link and Anchor is a JavaScript Object. Every Form, and every Element within a Form, is an HTML object. The hierarchical organization of display elements on a Web page is reflected almost exactly in a hierarchical set of nested HTML objects.

Browser Objects are at the top of JavaScript's Object hierarchy. These objects represent large scale elements of the browser's current environment, and include Objects such as window (the current window), History (the list of previously visited pages), and Location (the URL of the current page).

The Document Object Model (DOM) is a simple, hierarchical naming system that makes all of the objects in the page, such as images, forms, and even CSS properties, accessible to scripting languages like JavaScript.

Most HTML-based objects have DOM properties that match the attributes in their tags.

Overview of the Navigator Object Hierarchy

OBJECT

DESCRIPTION

navigator The navigator object provides properties that expose information about the current browser to JavaScript scripts
window The window object provides methods and properties for dealing with the actual browser window, including objects for each frame
location The location object provides properties and methods for working with the currently open URL
history The history object provides information about the history list and enables limited interaction with the list
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, anchors, and with applets

Built-in Objects

OBJECT

DESCRIPTION

String The string object enables programs to work with and manipulate strings of text, including extracting substrings and converting text to upper- or lowercase 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 root
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.