JavaScript(JS) array method - reverse

The reverse() method in JavaScript is used to reverse the order of elements in an array. It modifies the original array and returns the reversed array.

Here's an example of how to use the reverse() method:

let array = ["one", "two", "three", "four"];
array.reverse();
console.log(array); // ["four", "three", "two", "one"]
Sour‮gi.www:ec‬iftidea.com

In this example, we have an array array containing the elements ["one", "two", "three", "four"]. We use the reverse() method to reverse the order of the elements in the array.

The reverse() method modifies the original array and returns the reversed array. After the reverse() method is executed, the array is now ["four", "three", "two", "one"].

We log the reversed array to the console using console.log(array).