There are 3 ways to define an array in JavaScript a) Conventional array Conventional array looks like var mycars=new Array() mycars[0]="Toyota" mycars[1]="Honda" mycars[2]="Mitsubishi" You can expand and contract the array as desired, by adding new array elements with first array element should have an index number of 0. With a conventional array, you have choice of presetting the array's length when defining it, by passing in a numeric integer into the Array() constructor: var mycars=new Array(3) In this case 3 array elements will automatically be created, each with a value still "undefined." Also mycars.length will return 3. b) Condensed array The second way to define an array is called a Condensed array; it differs from Conventional array as it allows you to combine the array and array elements definitions into one step: var mycars=new Array("Toyota", "Honda", "Mitsubishi") This is suitable if you know all the array element values beforehand. c) Literal arrays The third way to define an array is called Literal array. Introduced in JavaScript1.2.
