
Array.length Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
446
|
ActionScript Language Reference
Array.length Property
the number of elements in an array
Flash 5
read/write
array.length
Description
The length property is a nonnegative integer specifying the number of elements in an array.
An array with no elements has a length of 0; an array with 2 elements has a length of 2.
Note that the index number of the first element in an array is 0, so
length is always one
greater than the index of the last element in the array.
The
length property of an array indicates how many numbered elements the array
currently contains, including empty elements (those containing
null or undefined). For
example, an array may have values for elements 0, 1, 2, and 9, but elements 3 through 8
may be empty. Such an array has a length of 10, because it has 10 element positions (0
through 9), even though only 4 positions are occupied by useful values.
The
length property changes automatically whenever any elements are added or removed
via the Array class methods, such as push(). The
length property reflects numbered
elements only; it does not include named array elements, which are treated as properties of
the Array object. Although we ordinarily use Array class methods to change
length indi-
rectly,
length can also be manipulated directly. Setting the length ...