PDA

View Full Version : multi-dimensional arrays


freddybee
01-29-2003, 12:59 AM
Hello,

I have no problem setting a 2-dimension array like that :

X = new Array(5,6)

X[4][5] = 2

But it doesn't work with a 3-dimension array :(

Does that mean that javascript is limited to 2 dimension ???

Thanks for your valuable help.

Fred

joh6nn
01-29-2003, 02:52 AM
var x = new Array(10);
x[0] = new Array(10);
x[0][0] = new Array(10);
x[0][0][0] = 5;

freddybee
01-29-2003, 03:51 PM
Originally posted by joh6nn
var x = new Array(10);
x[0] = new Array(10);
x[0][0] = new Array(10);
x[0][0][0] = 5;

Thank you for your help .... :thumbsup:
.... I still have a problem : with javascript you do not need to dimension your array in advance :
x = new Array()
x[156] = 15
works fine ....
... How could I achieve that with the 3 dimension array ???
:rolleyes:

Thank You

Borgtex
01-29-2003, 04:35 PM
Not sure if I understand the question, but...
x[156] = new Array();

joh6nn
01-29-2003, 04:36 PM
var x = new Array();
x[0] = new Array();
x[0][0] = new Array();
x[0][0][0] = 5;

freddybee
01-29-2003, 05:33 PM
Greaaaaat !

Thanks a lot ;)