I would like to create a 2d array, but i found an interesting behavior
const column = 10;
const row = 10;
let matrix = new Array(row).fill(new Array(column).fill(0));
matrix[0][1] = 1;
console.log(matrix)
and to my surprise i get the result as below:
0 2 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
the entire column number 1 is set to 1, may I know why am I getting this behavior?