necro Posted April 16, 2006 Share Posted April 16, 2006 could anyone help me in understanding how to create a two dimensional array (an array of arrays as it were) and then how to access info back out of it? Link to comment Share on other sites More sharing options...
raimo Posted April 16, 2006 Share Posted April 16, 2006 could anyone help me in understanding how to create a two dimensional array (an array of arrays as it were) and then how to access info back out of it?<{POST_SNAPBACK}> var myarray = new Array(3); // main arrayfor (var i = 0; i < 3; i++) myarray[i] = new Array(3); // sub arrays now we own 3 arrays with 3 sub arrays: myarray[0] -> [0][1][2]myarray[1] -> [0][1][2]myarray[2] -> [0][1][2] myarray[0][0] = "horse";myarray[1][2] = "cat";myarray[2][1] = "dog";if (myarray[2][1] == "dog") alert(myarray[0][0]); etc. hope this help? Link to comment Share on other sites More sharing options...
necro Posted April 16, 2006 Author Share Posted April 16, 2006 thanks! that makes sense now. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now