reverse ExampleΒΆ

The general syntax for this method is:

arrayName.reverse()

This method is straightforward - it reverses the order of the elements in the array.

No arguments are placed inside the parentheses ().

Example

1
2
3
4
let arr = ['At', 'banana', 'orange', 'apple', 'zoo'];

arr.reverse();
console.log(arr);

Output

[ 'zoo', 'apple', 'orange', 'banana', 'At' ]