HTML and CSS Reference
In-Depth Information
EXPLANATION
1
A new array object called
props
is created with the
Array()
constructor.
2
The
for/in
loop allows you to enumerate (list one by one) the properties of an ob-
ject, in this case the
document
object. The body of the
for/in
loop is executed once
for each property of the
document
object.
3
Each time through the loop, a new property of the
document
object is pushed onto
the
props
array.
4
This
for
loop iterates through the
props
array to list the properties that were as-
signed to it.
5
Each property of the
document
object is displayed in groups of three. The output
differs somewhat on different browsers.
Figure 11.2
Partial output showing the document's properties.
Using the
document
Object Properties in JavaScript.
Example 11.2 demon-
strates how the properties that describe the document are used in a JavaScript program.
The
write()
method displays a description of each of these properties as they pertain to
the current document. The background color is silver, the text is forest green, the unvis-
ited link is blue, and the visited link is purple.