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

Declaring a two-dimesional array in javascript

P: n/a
Hi to all,
I have this problem in declaring a two-dimesional
array, how will i declare such array with unknown number of rows?

Your help will be very much appreciated. Thanks in advance.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Lee
ms_chika said:

Hi to all,
I have this problem in declaring a two-dimesional
array, how will i declare such array with unknown number of rows?

Your help will be very much appreciated. Thanks in advance.


Javascript doesn't support two-dimensional arrays, but on the other
hand, you don't need to declare the number of elements in an array,
either.

var myArray=new Array();
myArray[237]=new Array();
myArray[237][12]="Hello, world!";

Jul 23 '05 #2

P: n/a
oh i see, how about this one ,another question. I have 3
two-dimensional array, i want to merge these 3 arrays so that it will
become only 1 two-dimensional array. Is it possible? If it is, how will
i dot that?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

P: n/a
ms_chika wrote:
oh i see, how about this one ,another question. I have 3
two-dimensional array, i want to merge these 3 arrays so that it will
become only 1 two-dimensional array. Is it possible? If it is, how
will i dot that?


Have you tried something like:

j=target_array.length;
for (var i=0; i<source_array.length; i++) {
target_array[j] = source_array[i];
j++;
}

?
HTH
Markus
Jul 23 '05 #4

P: n/a
ms_chika wrote:
Hi to all,
I have this problem in declaring a two-dimesional
array, how will i declare such array with unknown number of rows?

Your help will be very much appreciated. Thanks in advance.


var prem=
[["Arsenal",12,3,2],["Chelsea",12,5,0],["Fulham",6,6,6],["Tottenham",4,4,8]];

prem[1][0] =="Chelsea" //true

Mick
Jul 23 '05 #5

P: n/a
Thanks a lot, i got it. =)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.