JavaScript Array reverse()

The JavaScript Array reverse method returns the array in reverse order.

The syntax of the reverse() method is:


Here, arr is an array.

reverse() Parameters

The reverse() method does not take in any parameters.

Return Value from reverse()

  • Returns the array after reversing the order of its elements.

Note: The reverse() method reverses the order of elements in place, meaning that it changes the original array and no copy is made.

Example: Reversing the Elements of an Array

var languages = ["JavaScript", "Python", "C++", "Java", "Lua"];
console.log("Original Array: " + languages);

// reversing array order
reversed_arr = languages.reverse();

// reverse() modifies the original array
console.log("Array after reverse(): " + languages);

// reverse() also returns the reversed array
console.log("Return Value of reverse(): " + reversed_arr);


Original Array: JavaScript,Python,C++,Java,Lua
Array after reverse(): Lua,Java,C++,Python,JavaScript
Return Value of reverse(): Lua,Java,C++,Python,JavaScript

Here, we can see that the reverse() method reverses the order of array elements as well as returns the reversed array.

Recommened Reading: JavaScript Array sort()