[JavaScript]
[Previous page] [Section contents page] [Next page]
Objects

Like most modern programming languages, JavaScript is object-oriented, meaning that the preferred way for handling data and actions is through objects. Objects in computing are something like physical objects: we categorize them (or arrange them into classes), we give them names, we distinguish them by their different properties. Objects of different classes are distinguished by having different sets of properties; objects in the same class are distinguished by having different values for a common set of properties. We also do different things with different classes of objects, and data objects also have different action-potentials, or methods associated with them.

That's the conceptual overview; practically and technically speaking, an object in JavaScript is a name that has an array of properties and methods associated with it. You can create your own objects, but there are also a number of pre-defined objects that will probably serve many, perhaps even all, of you your needs, depending on how ambitious your scripting will be. The pre-defined objects fall into three general categories:

  • built-in objects (these are specific to the JavaScript language, and have nothing specifically to do with the Web)
  • browser objects (various objects associated with the user's web browser)
  • document objects (various objects associated with HTML documents)

Also note that some objects are children of others, meaning that they inherit some of the properties of the parent object. Here's a basic map of the major JavaScript objects for web developers:

JavaScript Object Hierarchy

Note here that the Window object is the parent of the important history, document, and location objects -- as a kind of "primal parent," it is generally assumed, and need not be named in references to its child objects. (In other words, window.location.href is equivalent to location.href.)

[Previous page] [Section contents page] [Next page]