• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

javascript array delcaration

can anyone tell me if the declaration of an array :

a=new Array(2,4);  is correct? -is it a bi-dimensional array?
0
costaf
Asked:
costaf
1 Solution
 
Om PrakashCommented:

var a  = new Array(2);  

for 2 dimensional array, you can do the following:
var a  = new Array(2);  

for (i=0; i <4; i++)
a[i]=new Array(4)

Open in new window

0
 
R-ByterCommented:
1. It is correct.
http://www.w3schools.com/js/js_obj_array.asp

2. Its not multidimensional array. To create multidimensional one:
http://stackoverflow.com/questions/2529865/javascript-multidimensional-array

Regards
0
 
zvytasCommented:
The declaration is syntactically correct, however it's not a bi-dimensional array. What you created is an array with two elements - 2 and 4. If you want a bi-dimensional array you should do the following:

a=new Array(new Array(4), new Array(4));
0
 
leakim971PluritechnicianCommented:
a={"0":new Array(2),"1":new Array(4)}
0
 
costafAuthor Commented:
thank you very much to you all!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Tackle projects and never again get stuck behind a technical roadblock.
Join Now