I am trying to make a copy of a javascript array and modify the 'copy' without modifying the original variable too, can anyone explain what I am doing wrong..
e.g
var array1 = [2, 5];
var array2 = '';
array2 = array1;
array2.pop();
console.log(array1);
console.log(array2);
// both output the same, however I want it to show array1 with 1 single item
I am trying to make it so array2 will only contain the one item in the array & array1 will contain two items in the array. Any ideas what I'm doing wrong?