Which built-in method reverses the order of the elements of an array?

Mighty96

BANNED
Joined
Sep 9, 2018
Messages
16
Reaction score
10
I know that the reverse method reverses the order of the elements of an array i.e the first becomes the last, and the last becomes the first.
apart from the reverse method is there any other method?
 
You can do array1.forEach(item => array2.unshift(item))
It will take item by item from the original array, and push it at the start of the array.

But why you need another way when reverse() is doing the same job?
 
If you are concerned about performance you can start iterating the array from the end
 
in PHP you can pop the last value of an array into your variable and then append it to a new array
 
Back
Top