When initial arrays contain undefined elements this code works great:
var x = [];
x[0] = ["title","t1"];
var y = []; y[0] = []; y[0][3]="t3";
console.log(x);
console.log(y);
y.forEach((subarr, i) => {
Object.assign(x[i], subarr);
});
console.log(x);
What should I change to make this code works for initial arrays which may contain null elements and undefined elements:
var x = [];
x[0] = ["title","t1"];
var y = []; y[0] = [null,undefined,null,"t3"];
console.log(x);
console.log(y);
y.forEach((subarr, i) => {
Object.assign(x[i], subarr);
});
console.log(x);
I'd like to get the same result as in the first example but for initial arrays which may contain null and undefined elements. Expected result:
[ [ "title", "t1", null, "t3" ] ]