Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

'mulit-dimensional' arrays in javascript

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could've swore you can create 2d arrays in javascript literally.

something like so...



how do I make one literally?

thanks,

Justin Fox
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64971
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: [[],[],[]]
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, I finally figured it out, I had the array coming back from the server in this format:



and in client side when in eval that text and loop through
it gave me this

a,b,c a,b,c a,b,c
a,b,c a,b,c a,b,c

But when I set it up in this format:



it looped through and printed it fine:

a b c
a b c
a b c

was weird, but I got it working.

Justin Fox
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic