Nov 21, 2009

Y = New Array()

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > How-To's and Tutorials > Programming > Client Side Scripting > Javascript

Y = New Array()

al-rafideen
Hi,
I have no problem with one dimension Array. For example:
Y = new Array();
Y[0] = smith;
Y[1] = john;
..
..

My problem is with two dimension Array. For example:
Y[0,0] = smith;
Y[0,1] = john;
..
..
Do you agree to define Y = new Array() with two dimension Array.
Thank you for your help in this matter.

Comment/Reply (w/o sign-up)

Jeigh
As far as I know (I may be wrong, I don't do a lot of javascript work) there are not true 2d arrays in javascript. You can, however, declare one array and then declare elements within that array as arrays which in effect is a multi-dimensional array. The site at http://www.javascriptkit.com/javatutors/twoarray1.shtml can show you an example and I found a bunch more just by quickly googling for '2d arrays in javascript'. It will likely take some playing around but if its important to your design I'm sure you can get something working that will be equivalent to having a 2 dimensional array.

Comment/Reply (w/o sign-up)

kelvinmaki
Actually declare Y = new Array() is for the top level of the array, not a 2D array. So afterwhich you've declared that, you need to declare another array inside of Y. So like,

Y = new Array();
Y[0] = new Array();
Y[1] = new Array();

Then you are allow to put data into Y[0] array. eg.

Y[0][0] = smith;
Y[0][1] = smith2;
Y[1][0] = john;
Y[1][1] = john2;

Now then you'll have a 2D array. I've gotten error not declaring new Array() for both cases. Hope this help. Cheers

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Array


    Looking for y, array,

See Also,

*SIMILAR VIDEOS*
Searching Video's for y, array,
advertisement



Y = New Array()

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com