fai960820 0 Posted March 14, 2013 Report Share Posted March 14, 2013 (edited) <script>int[][] num = new int[4][5];num[1][1]={0,1,2,3,4};alert(num[1][2]);</script> This give my an error " Uncaught SyntaxError: Unexpected token ] " (shown by chrome) #for the "int[][] num = new int[4][5];" line Please help. Edited March 14, 2013 by fai960820 Quote Link to post Share on other sites
justsomeguy 1,135 Posted March 14, 2013 Report Share Posted March 14, 2013 Javascript isn't C. You define an array like this: var num = new Array(); or var num = []; num[1][1]=[0,1,2,3,4]; You can create a for loop if you want to loop through and build the array. Quote Link to post Share on other sites
T1000Android 11 Posted March 20, 2013 Report Share Posted March 20, 2013 In javascript, there are no types like in C. The browser automatically figures out the type of the variable based on its value so there is no need for int, float, or char. Quote Link to post Share on other sites
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.