reverse()
Array
instance method setterS2C Home
« Globals « Array « reverse()
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);
Related Tutorials
JavaScript Intermediate Tutorials - Lesson 1 - Arrays