0

When I am changing the value of a copy of the original variable the original variable is getting changed.

The code below

function test(){
  var original= ['','','','1',''];
  var copyy=original;
  copyy[3]="2"; 
  console.log(original);
}

The console output is

 ["", "", "", "2", ""]

Not able to wrap my head around this. jsfiddle

Rohan Sharma
  • 1,416
  • 2
  • 14
  • 19

0 Answers0