It's a super cool array method, and it's easy to use.
To reverse an array, we can call the reverse method on a variable.
const array = ['a', 'b', 'c']; array.reverse(); // [ 'c', 'b', 'a' ]
As you can see, this reversed our initial input array.
You might not want to reverse the original array in some cases but want to create a copy.
const array = ['a', 'b', 'c']; const reverse = [...array].reverse(); // array: [ 'a', 'b', 'c' ] // reverse: [ 'c', 'b', 'a' ]
And that's it, reversing arrays is pretty straightforward and comes in super handy.
You can have a play with today's code in the following Codepen.