How to reverse the order of a JavaScript array?


To reverse the order of a JavaScript array, use the JavaScript array() method. JavaScript array reverse() method reverses the elements of an array. The first array element becomes the last and the last becomes the first.

Example

You can try to run the following code to reverse the order of a JavaScript array −

<html>
   <head>
      <title>JavaScript Array reverse Method</title>
   </head>
   <body>
      <script>
         var arr = c.reverse();
         document.write("Reversed array is : " + arr );
      </script>
   </body>
</html>

Updated on: 18-Jun-2020

240 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements