0

Could someone help me understand this?

Just to be sure the reverse method with (!) Changes the index of the array whilst the reverse method without the (!) saves the index position even when the elements changes positions ??????

7/17/2019 4:07:25 PM

Joseph Asukera

1 Answer

New Answer

+2

The functions with (!) do change the object. They are "destructive" as they destroy the object as you had it before. Functions without (!) are non-destructive. Rather than changing the object itself, they create a new object of the same kind but altered data. Reversing an array destructively reverses the array "in place" by rearranging the elements. Reversing non-destructively clones the array and reverses the elements in the clone and returns a reference to the clone thus leaving the original object in tact.