By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,604 Members | 1,649 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,604 IT Pros & Developers. It's quick & easy.

how to create a 3 dimensional array

P: 1
how to create a 3d array in javascript?
Oct 18 '07 #1
Share this Question
Share on Google+
3 Replies


gits
Expert Mod 5K+
P: 5,390
splitted from 'read first before posting' thread ... please create a new thread when posting a new question ...

kind regards
Oct 18 '07 #2

acoder
Expert Mod 15k+
P: 16,027
If you know how to create a 2D array, a 3D array is similar.

For example:
Expand|Select|Wrap|Line Numbers
  1. var arr = new Array(3);
  2. // create 2D
  3. for (i = 0; i < arr.length; i++) {
  4.  arr[i] = new Array(3);
  5. }
  6. // create 3D
  7. for (i = 0; i < arr.length; i++) {
  8.  for (j = 0; j < arr[0].length; j++) {
  9.   arr[i][j] = new Array(3);
  10.  }
  11. }
Oct 18 '07 #3

rnd me
Expert 100+
P: 427
this works:
Expand|Select|Wrap|Line Numbers
  1. r =[[[]]]
Jul 6 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.