Array properties
Provides a reference of the properties of arrays.
| Syntax | Effect |
|---|---|
| array[index] | If Otherwise, it is considered as a standard property access. If this element
has never been set, Example: Suppose
that the array Then: a[0] –> "foo" a[1] –> 12 a[2] –> true a[3] –> null a[1000] –> null When an element of an array is set beyond the current length of the array, the array is automatically expanded: a[1000] = "bar" // the array is automatically expanded.Unlike other properties,
the numeric properties of an array are not listed by the |
| array.length | The length of When a new element is set in
the array, and its index is greater than or equal to the current array
length, the Example:
Suppose that the array Then: a.length -> 3 a[100] = "bar"; a.length –> 101You can also change the length of an array
by setting its a = new Array(); a[4] = "foo"; a[9] = "bar" a.length –> 10 a.length = 5 a.length –> 5 a[4] –> "foo" a[9] –> null |