How to reverse the order of a JavaScript array?

JavascriptWeb DevelopmentFront End Technology

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>
raja
Published on 12-Feb-2018 17:10:20
Advertisements