i wrote a short Codepen where i tried to alter a temporary Array while keeping the original one, but both of my Arrays get altered.
Could someone explain me what the problem is?
var x = ["x"];
abc(x);
function abc(x){
  for(var i = 0; i < 3; i++) {
    var y = x;
    y.unshift("y");
    console.log(y);
    console.log(x);
  }
}
Output:
["y", "x"]
["y", "x"]
["y", "y", "x"]
["y", "y", "x"]
["y", "y", "y", "x"]
["y", "y", "y", "x"]
Thanks in advance.
 
     
    