Having an array intialized to a value, which would be the best way to merge to a second array over the first one?
var a = [[0,0,0,0], [0,0,0,0]]; // 2x4
var b = [[1,1], [2,2]];
For a simple dimension could be used:
var base = [0, 0, 0, 0, 0, 0, 0, 0];
var add = [1, 2, 3, 4];
for (i in add) {
base[i] = add[i];
}
>>> base
[1, 2, 3, 4, 0, 0, 0, 0]
But how about 2 or 3 dimensions?