December 2001
Intermediate to advanced
480 pages
9h 22m
English
One way to think of JavaScript objects is as associative arrays. From our discussion of arrays and using the for / in statement to pull information from objects, you might have already suspected as much. To demonstrate this fact, the following script builds an object, assigns data to it, and then pulls it apart as an array:
<html>
<head>
<title>Associative Array</title>
<script language="JavaScript">
var tree = new Object();
tree.size="Big and taller than Uncle Jim.";
tree.shade="It keeps us cool in the summer";
tree.fall="We make giant leaf pumpkins."
var display =tree["size"] + "<br>";
display +=tree["shade"] + "<br>"
display +=tree["fall"]
document.write(display); </script> </head> <body bgcolor="wheat" ...Read now
Unlock full access