There are two important notes.
array.concat()
does not work using Angular 1.4.4 and jQuery 3.2.1 (this is my environment).array.slice(0)
is an object. So if you do something like newArray1 = oldArray.slice(0); newArray2 = oldArray.slice(0)
, the two new arrays will reference to just 1 array and changing one will affect the other.Alternatively, using newArray1 = JSON.parse(JSON.stringify(old array))
will only copy the value, thus it creates a new array each time.