Arrays are ordered lists of information/data.

Ways to create Arrays:

1. simple constructor creates an empty array of zero length:
        myList = new Array();
                i. now you can assign values by index, e.g.:

                myList[0] = 2002;
                myList[1] = "Steve";


                        etc.
                ii. or assign them all at once with in a comma delimited list:

                myList = [2002, "Chris","Denise","Jenny","Jeff","Rudy"];

2. constructor with a single numeric argument creates an empty array with the specified number of empty elements:

        myList = new Array(5);

                        i. now you can assign values ...


3. constructor with comma-separated arguments:

        myList = new Array(2002, "Chris","Denise","Jenny","Jeff","Rudy");

4. simply assign a comma-separated list inside square brackets (an array literal) to a variable:

        myList = ["Chris","Denise","Jenny","Jeff","Rudy", 400 * Math.PI];

 

SPECIAL:

Create an ASSOCIATIVE ARRAY, a list of named elements (a.k.a, a hash):

        hash = new Array();
        hash["name"] = "john"
        hash["age"] = 27

All at once:

        hash = new Array();
        hash = {
                name: "john",
                age: 27
        }

 

Accessing Arrays:

The elements of an array are accessed by index.
To access the first element of an array:

  myVariable = myArray[0];

Arrays are zero indexed lists of variables, i.e., the first element's index is the number zero.
The index of the last element of an array is one less than the 'length' property of the array:

  myLastElement = myArray[myArray.length - 1];

 

Access Associative array:

        txt = hash["name"]

would set the value of the variable, 'txt', to "john".