Forum Moderators: open

Message Too Old, No Replies

Make multilevel Array

         

orion_rus

9:47 am on Oct 22, 2004 (gmt 0)

10+ Year Member



Hello i need to form array dinnamicaly, i need following construction
[[1,2,3],[1,2,3],[1,2,3]]
if don't create it before and make call like timer[1][0] it calls error if timer[1][0] not formed before, how i can make such array timer[][]?

Bernard Marx

11:20 am on Oct 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



2 dimensional arrays don't exist in Javascript, so you will have to fill your array with as many empty sub-arrays as you think you will need

timer = [[],[],[]]

If you really aren't sure, you will have to include statements that test to see if the sub-array exists before trying to access a member. If it doesn't, then you can create the array first.

rrobert

8:49 am on Oct 26, 2004 (gmt 0)


You kann do something like this:

var someArray = new Array();
someArray[0] = new Array();

and if you ned to be dinamic put it in loop:

for(i=0;i<somthing;i++){
someArray[i] = new Array();
}

I hope this is what you need.

orion_rus

2:26 pm on Oct 30, 2004 (gmt 0)

10+ Year Member



Thanx the information is very usefull,it helps