Two Dimensional Array in Javascript Object -


i want create object contains 1 or more 2 dimensional arrays in javascript.

i tried following way (in example try add 1 2 dimensional array):

var xsize = 8;   var ysize = 8;   var obj = {    field : new array(xsize),    field[0] : new array(ysize),    foo : 1,    bar : 100   } 

info:
- gives me strange error "missing : after property id" not seem make sense
- unfortunately didn't find examples showing how far using google
- if don't add field[0] ... creating 2nd array works.
- changing xsize , ysize numbers new array(8)... doesn't work.

i appreciate if show me how or explain why cannot @ , need use other method.

thanks lot!

the error "missing : after property id" because javascript sees field part of field[0] , expects colon before value of field. instead gets open bracket complains.

you can't hard code object definition has dimensions set @ run time. have build object @ run time well. perhaps

var xsize = 8;   var ysize = 8;  var obj = {    field : new array(),    foo : 1,    bar : 100   }  (var = 0; < xsize; i++) {   obj.field.push(new array(ysize)); } 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -