JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow Array Right Arrow reverse()

reverse()  Array  instance method

Description

Reverses the order of elements within an array.

Syntax


Signature Description
anArray.reverse()Reverses the order of elements within an array.

Parameters

None.

Examples

The code below creates an array then reverses the elements.


/*
 Create an array of numbers.
 Reverse the array.
 someNumbers = [3, 2, 1] after reverse().
 */
 var someNumbers = [1, 2, 3];
someNumbers.reverse();
alert(someNumbers);

Press the button below to action the above code:

Related Tutorials

JavaScript Intermediate Tutorials - Lesson 1 - Arrays



  

go to home page Homepage go to top of page Top