I would like to store testArray
in tempArray
, and then erase testArray
. In the code below tempArray
gets erased along with testArray
. Please explain why this isn't working along with a computationally minimal way of achieving this.
var testArray = new Array();
testArray.push("green");
alert(testArray.length);//returns one
var tempArray = new Array();
var tempArray = testArray;
alert(tempArray.length);//returns one
testArray.length = 0;
alert(tempArray.length);//returns zero