In this function, why this console.log is not returning the original array if I i'm not changing nothing yet?
var main =[
[2,0,0,0],
[0,0,0,0],
[4,0,0,0],
[4,0,0,0]
];
function rotateArray(){
let original = main;
console.log(main); //nothing should be afecting main for the moment
let x = 0;
for(let u = 0; u<original.length;u++){
let y= 3;
for(let i = 0; i<original[u].length;i++){
original[u][i]= main[y][x];
y--;
}
x++;
}
}
Console log output:
[4,4,0,4],
[0,0,0,4],
[0,0,0,0],
[0,0,4,4]
Why?