Home / Advanced JavaScript Tutorials / Creating dense arrays

 

 

CodingForums
Having trouble with scripting? Visit our help forum to get the answers you need.

Jump to...
-Free JavaScripts
-JS tutorials
-JS Reference
-DHTML/CSS

-Free applets
-Web Tutorials
-Link to Us!

- CSS Drive
- JavaScript Menus
- PHP Resources
- Hotels & Vacations
- Java Online Casinos
- Web hosting Search


Red_CurlyC035.gif (995 bytes) Improvements to dense arrays in Netscape 3

In Netscape 3 and up, access-by-name support was added to dense arrays. This means a programmer can access the values of a dense array not only through the value's index number, like above, but also, through its name. For example, the below also alerts "one":

alert(myarray["one"])   //alerts "one"

There are no particular advantages to accessing a dense array through the value's name other than that it provides better documentation (others can more readily see which values are being accessed).

Lets now demonstrate the true power of dense arrays by showing how it can significantly lessen the code required to create a script that writes out the current date and time.

-Tutorial introduction
-Quick review of declaring a "normal" array
-Overview of declaring dense arrays
-Improvements to dense arrays in Netscape 3
-Example: Writing out the current date and time using dense arrays

Example: Writing out the current date and time using dense arrays Small4.gif (1046 bytes)


http://javascriptkit.com
Copyright © 1997-2005 JavaScript Kit. NO PART may be reproduced without author's permission.