var oldArray = [],someArray=[],newArray=[];
oldArray = [4,5];
someArray =[1,2,3];
newArray = someArray;
for (var i=0; i<oldArray.length; i++){
someArray.push(oldArray[i]);
}
// I want this to be [1,2,3] but it becomes [1,2,3,4,5]
// due to scope issue I believe
oldArray = newArray;
newArray needs to be original someArray of [1,2,3] when oldArray = newArray, however due to scoping by the time that oldArray = newArray it becomes [1,2,3,4,5] instead.
How can I solve this issue? I need to preserve original someArray value and assign those values into oldArray.