So I have a matrix A, of dimension n*n, initialized with Array.fill()
like so.
var A = new Array(n).fill(new Array(n).fill(0))
That's cool and all however if I try to modify one of its values, the whole column modifies instead.
A[2][3] = 1
modifies the whole column 3.
Example snippet :
var n = 4;
var A = new Array(n).fill(new Array(n).fill(0));
console.log(JSON.stringify(A));
A[2][2] = 4;
console.log(JSON.stringify(A)); // ...
Why is that? o.O