While working on one of my project I encountered the following problem. following is the best representation of the problem I faced.
function get() {
return [0,0];
}
let arr:number[] = get(); // arr=[0,0]
let arr2:number[] = arr; // arr2=[0,0]
arr2[1] = arr2[1] + 1; // arr2=[0,1] arr[0,0]
console.log(arr); // outputs [0,1]
the program outputs [0,1] even though I never touched the variable arr. I think it is a bug or if not I would be grateful to know the underlying reasoning behind this output. Thanks in Advance