JavaScript reverse()Method

Array 对象参考手册JavaScript Array Object

Examples

Reverse the order of the elements in the array:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.reverse();

fruitsOutput result:

Mango,Apple,Orange,Banana

Try it Yourself »

Definition and Usage

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support reverse().


Syntax

array.reverse()

Return Value

Type Description
Array The array with the reversed order

Technical Details

JavaScript Version: 1.1


Array 对象参考手册JavaScript Array Object

Other Extensions