The Array object is used to store multiple values in a single variable.
The following code creates an Array object called myCars:
There are two ways of adding values to an array (you can add as many values as you need to define as many variables you require).
var myCars=new Array();
Now your array contains:
You can refer to a particular element in an array by referring to the name of the array and the index number. The index number starts at 0.
The following code line:
will result in the following output:
To modify a value in an existing array, just add a new value to the array with a specified index number:
Now, the following code line: