Returns an integer value one higher than the highest element defined in an array.
arrayObj.length |
Arguments
- arrayObj
-
Required. Any Array object.
Remarks
As the elements in a JScript array do not have to be contiguous, the length property is not necessarily the number of elements in the array.
If a value smaller than its previous value is assigned to the length property, the array is truncated, and any elements with array indexes equal to or greater than the new value of the length property are lost.
If a value larger than its previous value is assigned to the length property, the array is formally expanded, but no new elements are created.
Example
The following example illustrates the use of the length property. An array is declared, and two elements are added to it. Since the largest index in the array is 6, the length is 7.
В | Copy Code |
---|---|
var my_array : Array = new Array(); my_array[2] = "Test"; my_array[6] = "Another Test"; print(my_array.length); // Prints 7. |