Javascript - Array reverse() Method

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

Description

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

Syntax

array.reverse()

Parameters

None

Return

An Array, representing the array after it has been reversed

Example

Reverse the order of the elements in an array:

Demo

var myArray = ["XML", "Json", "Database", "Mango"];
console.log( myArray );/*from w w  w  .  jav a  2 s  .co m*/

myArray.reverse();
console.log( myArray);

Result