Assume the following array:
var arr = [0,0,{x:0,y:0}];
var newA = arr.slice(0);
arr[2].x =2;
arr[2].y =2;
console.log(newA)
x and y are coordinates that are supposed to be changed. How can I store them before a function is invoked and they change (perhaps pushing to a new array)? A shallow copy with slice won't work as the copied array will update the values dynamically.