The array object provides a means to store and manipulate a set of other objects. Arrays can store numeric values, strings, or other JavaScript objects. There are several different ways to create JavaScript arrays. For example, the following statement wears the same 3 same version of a stop:
var arr = ["One", "one", "three"];
var arr2 = new Array ();
Arr2[0] = "one";
ARR2[1] = "both";
ARR2[2] = "three";
Arr3.push ("one");
Arr3.push ("both");
Arr3.push ("three");
The first method defines ARR and uses [] to set its contents in a statement. The second method creates the Arr2 object and then uses the direct index assignment to increase the entry. The third method creates the Arr3 object, and then pushes the entry onto the array using the best selection push () method of the extended array.
To determine the number of elements in an array, you can use the length property of the array object, as shown in the following example:
var numofitems = arr.length;
The array follows a zero-based index, which means that the first item is on index 0, and so on. For example, in the following code, the value of the variable first is Monday, and the last value of the variable will be Friday:
Var
Week = ["Mondy", "Tuesday", "Wednesday", "Thursday", "Friday"];
var first = w [0];
var last = week[week.length-1];
JavaScript Basics-Using arrays