Here is what I attempted:
let array = Array(2).fill([]);
array[0].push(1);
Expected result: array = [[1], []]
Actual result: array = [[1], [1]]
Can someone explain why the second element is affected by the first in this scenario?
Appreciate any help in advance.