A
Archos
I want to initialize a multidimensional array to a determined value,
i.e. an array of dimensions [2][4] initialized to 1.
I can do:
var a2 = new Array(2); for (var i0=0; i0<2; i0++){ a2[i0]=new
Array(4); }
for (var i0=0; i0<2; i0++){ for (var i1=0; i1<4; i1++){ a2[i0]
[i1]=1; }}
or shorter:
var a2 = new Array(2); for (var i0=0; i0<2; i0++){ a2[i0]=new
Array(4); for (var i1=0; i1<4; i1++){ a2[i0][i1]=1; }}
But is there any another way to do it shorter? Without use `var a2 =
[[1,1,1,1], [1,1,1,1]]`
Thanks in advance!
i.e. an array of dimensions [2][4] initialized to 1.
I can do:
var a2 = new Array(2); for (var i0=0; i0<2; i0++){ a2[i0]=new
Array(4); }
for (var i0=0; i0<2; i0++){ for (var i1=0; i1<4; i1++){ a2[i0]
[i1]=1; }}
or shorter:
var a2 = new Array(2); for (var i0=0; i0<2; i0++){ a2[i0]=new
Array(4); for (var i1=0; i1<4; i1++){ a2[i0][i1]=1; }}
But is there any another way to do it shorter? Without use `var a2 =
[[1,1,1,1], [1,1,1,1]]`
Thanks in advance!