function makeRow(v=0){
const array = new Array(3);
array.fill(v);
return array;
}
function makeMatrix(v = 0){
const array = new Array(3)
array.fill(makeRow(v))
return array;
}
const a = makeMatrix()
a[0][1]=2
console.log(a)
/*
[
[0,2,0],
[0,2,0],
[0,2,0]
]
*/
as in the code above, why did I only manipulate item 0 of a, but the result is that each item has been changed
for a big solution