View Single Post
  #3 (permalink)  
Old 05-15-2008, 03:58 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Manipulating in array

Multidimensioned Arrays

In the same way that arrays contain integers or strings as values, multidimensional arrays contain arrays as their values. The syntax for a multidimensional array is as follows:

myArray = new Array([2,3,4], [5,5,9], [8,6,1])

To display the first item of the first array (which has an index of 0,0) you would need to use:

document.write(myArray[0][0])

This is known as a two-dimensional array, even though there are three arrays each with three values, as the highest index is 2,2. Referencing each of the items in multidimensional arrays can be cumbersome and confusing, and I have found it easiest to keep arrays singular and just have more of them as necessary, i.e. have three separate arrays rather than one two-dimensional array.
__________________
With,
J. Jeyaseelan

Everything Possible
Reply With Quote