contents   index   previous   next



global.getArrayLength()

syntax:

getArrayLength(array[, minIndex])

where:

array - an automatic array.

 

minIndex - the minimum index to use.

 

return:

number - the length of an array.

 

description:

This function should be used with dynamically created arrays, that is, with arrays that were not created using the new Array() operator and constructor. When working with arrays created using the new Array() operator and constructor, use the length property of the Array object. The length property is not available for dynamically created arrays which must use the functions, global.getArrayLength() and global.setArrayLength(), when working with array lengths.

 

The getArrayLength() function returns the length of a dynamic array, which is one more than the highest index of an array, if the first element of the array is at index 0, which is most common. If the parameter minIndex is passed, then it is used to set to the minimum index, which will be zero or less. You can use this function to get the length of an array that was not created with the Array() constructor function.

 

This function and its counterpart, setArrayLength(), are intended for use with dynamically created arrays, that is, arrays not created with the Array() constructor function. Use the Array length property to get the length of arrays created with the constructor function and not getArrayLength().

 

see:

global.setArrayLength(), Array length

 

example:

   // automatic object array

var arr;

arr[0] = "zero";

arr[1] = 1;

arr[2] = 2;

Screen.writeln(getArrayLength(arr));   // 3

 

   // JavaScript Array object

var arr = ["zero", 1, 2]

Screen.writeln(arr.length);            // 3

 


global.getAttributes()