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. Link to comment https://forums.phpfreaks.com/topic/50111-solved-2d-array-problems/ 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. Link to comment https://forums.phpfreaks.com/topic/50111-solved-2d-array-problems/#findComment-246098 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]); Link to comment https://forums.phpfreaks.com/topic/50111-solved-2d-array-problems/#findComment-246266 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. Link to comment https://forums.phpfreaks.com/topic/50111-solved-2d-array-problems/#findComment-246641 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.