HTML and CSS Reference
EXAMPLE 8.2 ( CONTINUED )
document.write("<b>The toy is a " + toy.name + ".");
document.write("<br />It is a " + toy.color +""
+ toy.shape + ".");
The Object() constructor is called with the new keyword to create an instance of
an object called toy . A reference to the new object is assigned to the variable, toy .
(All objects are descendants of the Object o bject.)
The toy object's name property is assigned “Lego” . The properties describe the
characteristics or attributes of the object. Properties are not variables. Do not use
the var keyword.
The global object called toy is available within the script. The value of the toy ob-
ject's name property is displayed.
The values for the color and shape properties of the toy object are displayed.
Figure 8.3 The toy object and its properties.
window.document.bgColor = "lightblue";
The window is the top object in the Browser Object Model. It is the parent of all par-
ents; the document is an object but, because it is subordinate to the window , it is also a
property of the window object. Although the background color, bgColor , is a property of
the document object, by itself it is not an object. (It is like an adjective because it
describes the document.)