NME Posted May 5, 2007 Share Posted May 5, 2007 stack[1]=new Array(2); stack[2]=new Array(2); stack[1,1]="hello"; stack[2,1]="world"; document.write(stack[1,1] + " " + stack[2,1]); quick question.. why does the above write out the following: "world world"; i need it to write out: "hello world"; any ideas. thanks. Quote Link to comment Share on other sites More sharing options...
fenway Posted May 5, 2007 Share Posted May 5, 2007 I've never seen that syntax in my life. Quote Link to comment Share on other sites More sharing options...
NME Posted May 5, 2007 Author Share Posted May 5, 2007 ? what do u mean? am i making 2d arrays incorrectly? im under the impression that to make 2d arrays in javascript, one must do the following: (ie for a 2x2 array). var stack = new Array(2); stack[1] = new Array(2); stack[2] = new Array(2); stack[1,1]="hello"; stack[2,1]="world"; document.write(stack[1,1] + " " + stack[2,1]); Quote Link to comment Share on other sites More sharing options...
fenway Posted May 6, 2007 Share Posted May 6, 2007 I was not familiar with the comma in the square brackets... I guess I never used 2D arrays. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.