Javascript examples for Array:reverse
The reverse() method reverses the order of the elements in an array.
None
An Array reversed
The following code shows how to Reverse the order of the elements in an array:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> var fruits = ["a","b","c","d","e"]; document.getElementById("demo").innerHTML = fruits; function myFunction() {/* ww w. j ava 2 s .co m*/ fruits.reverse(); document.getElementById("demo").innerHTML = fruits; } </script> </body> </html>