reverse (JavaScript)

Reverses the order of the elements of an array.

Defined in

Array (Standard - JavaScript)

Syntax

reverse() : void

Usage

This method modifies the base array.

Examples

This computed label reverses the elements of an array.
var a = new Array("one", "two", "three");
a.reverse();
var display = "";
for(var i=0; i<a.length; i++) {
	display = display + a[i] + " ";
}
display // three two one