symdesign
1/17/2016 - 11:44 AM

Copy Array

... as "newArray = oldArray" does not copy the array but only the references of the objects in the array (so every change to newArray is also applied to oldArray), there is the method slice() to do that

// http://stackoverflow.com/questions/597588/how-do-you-clone-an-array-of-objects-in-javascript
newArray = oldArray.slice(0);