Check out my code snippet here: http://jsfiddle.net/sepoto/Zgu9J/1/
I've started by creating a function that reverses an array:
function reverseArray(input) {
var reversed = new Array;
for(var i = input.length-1; i >= 0; i--) {
reversed.push(input[i]);
}
//I attempted changing the return value to
//return reversed.slice(0), but it did not create
//an independent copy as intended
return reversed;
}
The second array I created, pointOrigins2, is not truly independent of pointOrigins1. Any modifications made to pointOrigins2 are also reflected in pointOrigins1, which is not the desired behavior. Despite trying suggestions from StackOverflow such as using slice or a for loop, I have not been able to achieve the desired result yet, hence I created this fiddle.
Is there a way to produce an independent copy of the reversed array?