JavaScript Editor JavaScript Debugger     JavaScript Editor 

Team LiB
Previous Section Next Section

Chapter 6: Objects

JavaScript is an object-based language. With the exception of language constructs like loops and relational operators, almost all of JavaScript’s features are implemented using objects in one way or another. Sometimes objects are used explicitly to carry out certain tasks, such as the manipulation of (X)HTML and XML documents using the Document Object Model. Other times, the role of objects in the language is less obvious, like the role played by the String object during the manipulation of primitive string data. While previous chapters presented examples that implicitly demonstrated the use of built-in objects, this chapter will explore JavaScript objects directly.

Objects in JavaScript

Objects in JavaScript fall into four groups:

The objects in JavaScript are summarized in Table 6-1.

Table 6-1: The Four Types of Objects Available to JavaScript



Implementation Provided By

Governing Standard


Programmer-defined Customer or Circle




Array, Math

The browser via its JavaScript engine



Window, Navigator

The browser

None (though some portions adhere to an ad hoc standard)


Image, HTMLInputElement

The browser via its DOM engine


There is some overlap in these four categories. For example, before the advent of the official DOM standard, objects such as Image were browser objects because each vendor implemented their own feature set. The major reason there is such overlap is that there is no one standard governing how all aspects of JavaScript are supposed to behave. The ECMA-262 standard governs the nuts and bolts of the language itself. The W3C’s DOM specification dictates how structured documents like Web pages should be presented to a scripting environment. Browser vendors define access to the user interface as they see fit and even create their own proprietary extensions to the DOM. The result is a chaotic and somewhat confusing set of technologies that come together under the umbrella of “JavaScript.”

The good news is that browser vendors have finally settled on a de facto standard for browser objects. This “standard” is more an artifact of historical circumstances and browser wars than the product of a rational design process. This is evidenced by the fact that the Navigator object is supported by Opera, Netscape, and Internet Explorer despite obviously deriving its name from Netscape’s original Navigator browser. While the features implemented by Navigator objects are somewhat consistent across browsers, a close examination reveals some variation in the support of its properties by the different browser types and versions.

This chapter covers the fundamental ways that objects behave and can be manipulated in JavaScript. The specific capabilities of built-in, browser, and document objects are discussed in detail in chapters that follow.

Team LiB
Previous Section Next Section

JavaScript Editor JavaScript Debugger     JavaScript Editor