Received a question which I cant able to give the reason,
Declared a variable var arr1 = [2, 3];
then copied to another variable var arr2 = arr1;
Finally push arr2[0] = 1;
and the entire code looks like this,
var arr1 = [2, 3];
var arr2 = arr1;
arr2[0] = 1;
console.log(arr1, arr2);
The result we expect is [2, 3] [1, 3] but unexpectedly received [1, 3] [1, 3] i.e., Both the array values got updated.
Can anyone please mention why both the array results the same values?