Click to See Complete Forum and Search --> : Deep arrays?


Windchill
05-23-2003, 10:59 AM
Can javascript do deep arrays?
:confused:
EG: map[5,3]=2

I have tried and all I can get to work is:
map[5]=2

If I do
map[5,1]=2
map[5,2]=3
document.write( map[5,2] )

all I get is "2" not 3 :(

A1ien51
05-23-2003, 11:16 AM
here I have an explaination on multi-demensional arrays..

http://www10.brinkster.com/A1ien51/basics/2darray.htm

Eric

pyro
05-23-2003, 11:18 AM
Sounds like you are talking about multidimensional arrays, like this:

<script language="JavaScript" type="text/JavaScript">

a = ["value 0","value 1","value 2"];
a[0] = ["subvalue 0", "subvalue 1"];
alert (a[0][1]);

</script>

Windchill
05-23-2003, 11:19 AM
Thanks(wow, record reply time: 1 minute 57 seconds :D )

Charles
05-23-2003, 11:34 AM
You must, however, be careful when working with arrays and you use the 'language' attribute with the SCRIPT element. When you use that depricated attribute Netscape will use a non-standard Array.toString() method. And that method is sometimes called implicitly. Said attribute was depricated with good reason.