I passed an array(lets call it originalArr) to a function and then i assigned it to a new variable (lets call it copyArr) and when i changed the contents of the copyArr then the contents of the originalArr also changed example code
justAFunction([1,2,3,4,5,6,7,8]);
function justAFunction(originalArr){
let copyArr = originalArr;
copyArr.pop();
copyArr.pop();
copyArr.pop();
console.log(originalArr);
}
output = [ 1, 2, 3, 4, 5 ]
Can some one explain why this is happening