Previous Example-|-Next Example-|-Return to Chapter Listing

Example 9.8:
Creating an Array Using a Shortcut

[This example works with Netscape Navigator 3 and Internet Explorer 3.]

This is almost exactly the same as previous example; this time, though, we created the array using a shortcut. We typed var info = new Array(123, 456, 789).


This is the script we used in the HEAD: <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- var info = new Array(123, 456, 789) function showArray(a) { var l = a.length var i document.write("<BR>Array length is " + l + ".<BR>") for (i = 0; i < l; i++) { document.write("Item " + i + " is " + a[i] + ".<BR>") } } //--> </SCRIPT> And here's the script in the BODY: <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- info[9] = "the end" showArray(info) //--> </SCRIPT>
Previous Example-|-Next Example-|-Return to Chapter Listing