View Single Post
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Adding Array To Another Array

 
0
  #4
Nov 22nd, 2008
Just a quick brief regarding arrays. Since an Array can store other Arrays you can get the benefit of multi-dimension arrays.

var x=[0,1,2,3,4,5]; var y=[x];
In the above example i've created an array named "x" and assigned it as the first element in the array "y". If we ask for the value of y[0] it will return the contents of "x" as a string because we didn't specify an index.

var x=[0,1,2,3,4,5]; var y=[x]; document.writeln(y[0]); // Will output: 0,1,2,3,4,5
If we wanted the third index we'd access it this way...

var x=[0,1,2,3,4,5]; var y=[x]; document.writeln(y[0][3]); // Will output: 2
There's no defined limit to how many Arrays you can nest in this manner. For instance...

document.writeln(bigArray[5][8][12][1])
...would indicate bigArray's 5th index held an array, who's 8th index held an array, who's 12th index held an array, who's first index contains the data we want.
Reply With Quote