Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

JavaScript Array reverse() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

JavaScript Array.reverse() Method is used for the in-place reversal of the array. The first element of the array becomes the last element and vice versa.

Syntax:

arr.reverse()

Parameters: This method does not accept any parameter

Return value: This method returns the reference of the reversed original array.

Below examples illustrate the JavaScript Array reverse() Method:

Example 1: 

JavaScript




function func() {
    // Original Array
    let arr = ['Portal', 'Science',
        'Computer', 'GeeksforGeeks'];
    console.log(arr);
 
    // Reversed array
    let new_arr = arr.reverse();
    console.log(new_arr);
}
func();

Output:

Portal,Science,Computer,GeeksforGeeks
GeeksforGeeks,Computer,Science,Portal

Example 2: In this example, the reverse() method reverses the sequence of the array elements of arr.

JavaScript




function func() {
 
    // Original Array
    let arr = [34, 234, 567, 4];
    console.log(arr);
 
    // Reversed array
    let new_arr = arr.reverse();
    console.log(new_arr);
}
func();

Output:

[34, 234, 567, 4]
[4, 567, 234, 34]

We have a complete list of Javascript Array methods, to check those please go through this Javascript Array Complete referencearticle.

Supported Browsers: The browsers supported by the JavaScript Array reverse() method are listed below:

  • Google Chrome 1.0 and above
  • Microsoft Edge 12 and above
  • Mozilla Firefox 1.0 and above
  • Safari 1 and above
  • Opera 4 and above

We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.


My Personal Notes arrow_drop_up
Last Updated : 18 May, 2023
Like Article
Save Article
Similar Reads
Related Tutorials