Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (19 June 2013 - 02:28 PM) Long Life To Asta New Era
@  agyat : (19 June 2013 - 01:58 PM) New Era Start At Asta Or Asta Start In New Era. :unsure:
@  yordan : (16 June 2013 - 05:41 PM) You're Welcome, Agyat!
@  agyat : (16 June 2013 - 07:38 AM) Thanks Yordan...
@  velma : (16 June 2013 - 12:06 AM) I Have Asked Opa To Check For A Backup.. He'll Let Me Know Soon :)
@  velma : (16 June 2013 - 12:05 AM) T_T It Seems That Someone Has Deleted That Topic Since I Found The Url Of The Topic But It Gives Me An Error
@  yordan : (15 June 2013 - 10:31 PM) @velma : It's A Tuto On How To Create A Login Program.
@  yordan : (15 June 2013 - 10:31 PM) Happy Birthday To Youuuuuu Agyat!
@  yordan : (15 June 2013 - 10:31 PM) Ba$
@  agyat : (15 June 2013 - 04:41 PM) :(
@  agyat : (15 June 2013 - 04:41 PM) Where The Hall I Were? 15Th Is Almost At End And No-One Wished Me "happy Birthday"!!!
@  velma : (14 June 2013 - 10:39 AM) Which Tutorial Is He Searching For?
@  velma : (14 June 2013 - 10:38 AM) Which Tutorial Is He Searching For?
@  yordan : (14 June 2013 - 07:47 AM) Ok, Have A Look Tomorrow.
@  yordan : (13 June 2013 - 03:19 PM) @velma, Can You Have A Look At Feelay's Problem? Seems That His Tutorial Is Not Searchable Today.
@  Feelay : (13 June 2013 - 08:11 AM) Oh, Haha
@  velma : (12 June 2013 - 05:39 PM) T_T Lately My Levels Of Procrastination..... **sigh**
@  velma : (12 June 2013 - 05:38 PM) I'll Do It Later
@  velma : (12 June 2013 - 05:38 PM) Procrastinators.. People Who Keep Saying "i'll Do This In A Bit"
@  Feelay : (12 June 2013 - 02:05 PM) Deal Punishments To What?

Photo
- - - - -

Y = New Array()


2 replies to this topic

#1 al-rafideen

al-rafideen

    Newbie [ Level 1 ]

  • Members
  • 5 posts
  • Gender:Male
  • Location:uk

Posted 12 December 2007 - 05:49 PM

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.

#2 Jeigh

Jeigh

    Whitest Black Mage

  • Members
  • 1,381 posts
  • Gender:Male
  • Location:NB, Canada
  • Interests:My interests are my hobbies, and ironically enough my hobbies are my interests. I'm quite interested in my hobbies, much more so then my interests... but I spend more time with my interests as my hobbies are often rude with me so I don't enjoy talking to them as much.
  • myCENTs:93.97

Posted 12 December 2007 - 10:16 PM

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.javascrip...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.

#3 kelvinmaki

kelvinmaki

    Advanced Member

  • Members
  • 170 posts
  • Gender:Male

Posted 13 December 2007 - 03:06 PM

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



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users