I have these two arrays:
let num1 = [[1]];
const num2 = [2, [3]];
I concat these two and create new array:
const numbers = num1.concat(num2);
console.log(numbers);
// results in [[1], 2, [3]]
Now I push a new value to num1:
num1[0].push(4);
console.log(numbers);
// results in [[1, 4], 2, [3]]
But if I write:
num1[0] = [1, 4, 5];
console.log(numbers);
// results in [[1], 2, [3]]
Why reassigning vale to num1
does not reflect change in numbers array but push method does?