zero_point Posted November 24, 2013 Share Posted November 24, 2013 (edited) Hi all, how can I create 2D array ... like this .... var array = [][] ... you know what I mean ... like in other languages ... is it possible? Edited November 24, 2013 by zero_point Link to comment Share on other sites More sharing options...
Ingolme Posted November 24, 2013 Share Posted November 24, 2013 You have to decide the length of the array before hand and then create arrays as elements of the parent one. var a = [];a[0] = [];a[1] = [];a[2] = [];a[3] = [];a[4] = []; Link to comment Share on other sites More sharing options...
davej Posted November 24, 2013 Share Posted November 24, 2013 This seems to work... var row;var arr = [];var rows = 24;var cols = 7;for(var i=0 ; i<rows ; i++){ row = []; for(var j=0 ; j<cols ; j++){ row[j] = 1000+j+10*i; } arr.push(row);} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now