Java Reference
In-Depth Information
personnel[0][2]
=
"Address0";
personnel[1]
=
[];
personnel[1][0]
=
"Name1";
personnel[1][1]
=
"Age1";
personnel[1][2]
=
"Address1";
personnel[2]
=
[];
personnel[2][0]
=
"Name2";
personnel[2][1]
=
"Age2";
personnel[2][2]
=
"Address2";
document.write("Name : "
+
personnel[1][0]
+
"<br/>");
document.write("Age : "
+
personnel[1][1]
+
"<br/>");
document.write("Address : "
+
personnel[1][2]);
</script>
</body>
</html>
If you load it into your web browser, you'll see three lines written into the page, which represent the
name, age, and address of the person whose details are stored in the
personnel[1]
element of the array,
as shown in Figure 2-11.
figure 2-11
The first thing to do in this script block is declare a variable,
personnel
, and tell JavaScript that you
want it to be a new array:
var personnel
=
[];
Then you do something new; you tell JavaScript you want index
0
of the
personnel
array, that is, the
element
personnel[0]
, to be another new array:
personnel[0]
=
[];