Arrays and collections can be accessed using numeric indexing where each pocket is referred to by a number.
The array may be sparse and not all entries need to be assigned, but the length value will be set to one greater than the highest numbered entry. The first numbered entry is item 0.
You can also use strings instead of numbers. These string values can be specified literally or be passed with a variable.
These are all valid array element references:
myIndex = "three";
myArray[0] = "A";
myArray[100] = "B";
myArray["one"] = "C";
myArray['two'] = "D";
myArray[three] = "E";
Prev | Home | Next |
Assignment operator | Up | Associativity |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |