Returns an integer value that is 1 larger than the subscript of the highest bit element defined in the array.
numVar = arrayObj.length
Parameters
Numvar
Required option. Any number.
Arrayobj
Required option. Any Array object.
Description
Because the elements in an array are not necessarily contiguous, the length property is also not necessarily equal to the number of elements in the array. For example, in the following array definition, the My_array.length contains 7 instead of 2:
var my_array = new Array( );my_array[0] = "Test";my_array[6] = "Another Test";
If the length property is given a value that is smaller than the original value, the array is truncated and all elements of the array subscript equal to or greater than the new value of the length property are lost.
If the length property is given a value larger than the original, the array is extended and all new elements are assigned to undefined.
The following example illustrates the use of the length property:
function LengthDemo(){ var a; a = new Array(0,1,2,3,4); return(a.length);}
Requirements
Version 2
Please see
Length Property (Function) | Length Property (String)
Apply to: Array Object