Array reverse()

In this chapter you will learn:

  1. How to reverse a Javascript array

reverse():Reordering array

reverse() method reverses the order of items in an array.

<!DOCTYPE html><!--  j av a  2s .c om-->
<html>
<head>
    <script type="text/javascript">
        var values = [1, 2, 3, 4, 5]; 
        values.reverse(); 
        document.writeln(values); //5,4,3,2,1 
       
    </script>
</head>
<body>
</body>
</html>

Click to view the demo

reverse() returns a reference to the resulting array.

Next chapter...

What you will learn in the next chapter:

  1. How to slice a Javascript array
  2. How to use negative value with slice method
Home » Javascript Tutorial » Array
Array Type
Array creation
Array type detecting
Array iterate
Array Length
Add to Array
Array join
Array concat()
Array every method
Array search from start with indexOf()
Array search from the end with lastIndexOf()
Array filter
Array mapping
Array forEach
Array pop and push
Array shift()
Array reduce()
Array reduceRight()
Array reverse()
Array slice()
Array some()
Array splice()
Array sort()
Array toString()
Array unshift()