Declaring an Array
Like variables, arrays must be declared before they can be used. The new keyword is used to dynamically create the Array object. It calls the Array object's constructor, Array(), to create a new Array object. The size of the array can be passed as an argument to the constructor, but it is not necessary. Values can also be assigned to the array when it is constructed, but this is not required either. Let's examine some ways to create an array.
The following array is called array_name and its size is not specified.
var array_name = new Array();
In the next example, the size or length of the array is passed as an argument to the Array() constructor. The new array has 100 undefined elements.
var array_name = new Array(100);
And in the next example, the array is given a list of initial values of any data type:
var array_name = new Array("red", "green", "yellow", 1 ,2, 3);