Copy array by value
Use this: Basically, the slice() operation clones the array and returns a reference to a new array. Also note that: For references, strings and numbers (and not the actual object), slice() copies object references into the new array. Both the original and new array refer to the same object. If a referenced object changes, the changes are visible to both … Read more