The arr
array was changed only once.
The splice()
method removed all the elements in it, starting from index 2, and returned a new array of deleted elements.
The push()
method worked only with this returned array of deleted elements and did not change the arr array.