An Array is a special class of object that refers to its properties with numbers rather than with variable names. Properties of an Array object are called elements of the array. The number used to identify an element, called an index, is written in brackets following an array name. Array indices must be either numbers or strings.
Array elements can be of any data type. The elements in an array do not all need to be of the same type, and there is no limit to the number of elements an array may have.
The following statements demonstrate assigning values to arrays.
var array = new Array();
array = "fish";
array = "fowl";
array["joe"] = new Rectangle(3,4);
array[foo] = "creeping things"
array[goo + 1] = "etc."
The variables foo and goo must be either numbers or strings.
Since arrays use a number to identify the data they contain, they provide an easy way to work with sequential data. For example, suppose you wanted to keep track of how many jellybeans you ate each day, so you can graph your jellybean consumption at the end of the month. Arrays provide an ideal solution for storing such data.
var April = new Array();
April = 233;
April = 344;
April = 155;
April = 32;
Now you have all your data stored conveniently in one variable. You can find out how many jellybeans you ate on day x by checking the value of April[x]:
for(var x = 1; x < 32; x++)
Screen.write("On April " + x + " I ate " + April[x] +
Arrays usually start at index , not index . Note that arrays do not have to be continuous, that is, you can have an array with elements at indices 0 and 2 but none at 1.
array.jsh - arrays and objects
Array object instance properties
Array object instance methods