To declare a variable that contains an empty array, you use square brackets with nothing between them:
>>> var a = ; >>> typeof a;
typeof returns "object", but don't worry about this for the time being, we'll get to that when we take a closer look at objects.
To define an array that has three elements, you do this:
>>> var a = [1,2,3];
When you simply type the name of the array in the Firebug console, it prints the contents of the array:
[1, 2, 3]
So what is an array exactly? It's simply a list of values. Instead of using one variable to store one value, you can use one array variable to store any number of values as elements of the array. Now the question is how to access each of these stored values?
The elements contained in an array are indexed with consecutive numbers starting from zero...