The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

reverse Method (JavaScript)

Reverses the elements in an Array.



Required. Any Array object.

The reversed array.

The required arrayObj reference is an Array object.

The reverse method reverses the elements of an Array object in place. It does not create a new Array object during execution.

If the array is not contiguous, the reverse method creates elements in the array that fill the gaps in the array. Each of these created elements has the value undefined.

The following example illustrates the use of the reverse method.

var arr = new Array(0,1,2,3,4); 
var reverseArr = arr.reverse();

// Output:
// 4,3,2,1,0

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft