let matrix = new Array(3).fill(new Array(3).fill(0)); // creates a 2d Array and fills them with 0
matrix[1][1] = 5; // say
console.log(matrix); // should output [[0, 0, 0],[0, 5, 0],[0, 0, 0]
// actual-output: [[0, 5, 0], [0, 5, 0], [0, 5, 0]]
Why is it the output so weird! what is the fill method actually doing?