Array reverse :- JavaScript



The reverse() method used to reverse the order of the elements in an array.










Code:-


  • <!DOCTYPE html> 
    1. <html> 
    2.  
    3. <head> 
    4.  <meta name="viewport" content="width=device-width, initial-scale=1"> 
    5. </head> 
    6.  
    7. <body> 
    8.  
    9.  <h1>reverse()</h1> 
    10.  <h1>ar = ["G","X","Q","A","Z","B"]</h1> 
    11.  
    12.  <input type="button" onclick="ar_rev();" value="Inserted Array Values"> 
    13.  
    14.  <script> 
    15.   function ar_rev() 
    16.   { 
    17.  
    18.    var ar = ["G", "X", "Q", "A", "Z", "B"]; 
    19.  
    20.    alert("Actual : " + ar); 
    21.  
    22.    alert("Reveresed Array : " + ar.reverse()); 
    23.   } 
    24.  </script> 
    25.  
    26. </body> 
    27.  
    28. </html>

    Array reverse :- JavaScript Array reverse :- JavaScript Reviewed by Network security on August 06, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.