Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

javascript array delcaration

Posted on 2011-09-07
5
Medium Priority
?
173 Views
Last Modified: 2012-06-21
can anyone tell me if the declaration of an array :

a=new Array(2,4);  is correct? -is it a bi-dimensional array?
0
Comment
Question by:costaf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 22

Expert Comment

by:Om Prakash
ID: 36495526

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
 
LVL 14

Expert Comment

by:R-Byter
ID: 36495539
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
 
LVL 5

Accepted Solution

by:
zvytas earned 2000 total points
ID: 36495556
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
 
LVL 82

Expert Comment

by:leakim971
ID: 36495586
a={"0":new Array(2),"1":new Array(4)}
0
 
LVL 2

Author Closing Comment

by:costaf
ID: 36495679
thank you very much to you all!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question