Arrays
In JavaScript an array is created as follows:
// Creating an array
var priority = new Array();
priority[0] = "Low";
priority[1] = "Normal";
priority[2] = "High";
// Literal array
var priority = ["Low","Normal","High"];
Note:
JavaScript Arrays are zero base.
An element is accessed in the array by index number:
// To access the first element
var level = priority[0];
// To modify the first element
priority[0] = "Not required";
You can have different types in an array:
var entry = new Array();
entry[0] = Date.now;
entry[1] = "Book";
entry[2] = 5.99;
In JavaScript an array is an object, so an array can be an element in an array.
See Array for properties and methods.
See also Associative Array.