q = [3,2,4,1]
let copyQ = q;
copyQ.sort();
console.log(q) // 1,2,3,4 --------> This doesnt make sense.
console.log(copyQ) //1,2,3,4 -----> This makes sense
I had expected that q would remain the same, i.e unsorted as in line 1, because we had sorted copyQ, but it is not the case.
Whats going on there?