I have a array with 3*3
dimension(2d) like this:
a[3][3]=[[1,2,3],[4,5,6],[7,8,9]];
I want formulate this array to access in single array(1d). how I can do this? like:
b[9]=[0,1,2,3,4,5,6,7,8,9];
I have a array with 3*3
dimension(2d) like this:
a[3][3]=[[1,2,3],[4,5,6],[7,8,9]];
I want formulate this array to access in single array(1d). how I can do this? like:
b[9]=[0,1,2,3,4,5,6,7,8,9];
you want to convert a 2d array to a flat array. How about:
var a = [[1,2,3],[4,5,6],[7,8,9]];
var merged = [];
merged = merged.concat.apply(merged, a);
var flatArray = [];
for(var i=0;i<a.length;i++){
for(var j=0;j<a[i].length;j++){
flatArray.push(a[i][j]);
}
}