HTML and CSS Reference
In-Depth Information
EXPLANATION
1
The book constructor function is defined with its properties.
2
The book object is described with three properties: title , author , and publisher .
3
The book object's property is assigned the name of a function. This property will
serve as a method for the object.
4
A function called show is defined.
5
The with keyword will allow you to reference the properties of the object without
using the name of the object and the dot or the this keyword. (See “The Math Ob-
ject” on page 241 in Chapter 9.)
6
A variable called info is assigned the property values of a book object. The with
keyword allows you to specify the property name without a reference to the object
(and dot) preceding it.
7
The alert box displays the properties for a book object.
8
The constructor function is called and returns an instance of a new book object
called childbook .
9
The constructor function is called and returns an instance of another book object
called adultbook .
10
The show() method is called for the childbook object (see Figure 8.10).
11
The show() method is called for the adultbook object (see Figure 8.11).
Figure 8.10 The childbook object and its properties.
Search WWH ::




Custom Search