How to Reverse an Array in JavaScript

To reverse an array in JavaScript, use the .reverse() method. Pass it after the array using a . (dot).

 

JavaScript .reverse() Syntax

The JavaScript .reverse() method accepts no arguments and must be supplied after the array to modify.

 

array.reverse()

 

Reversing a JavaScript Array Example

Here is an example of how to reverse an array in JavaScript. It is important to note that the original array is changed by this method.

 

var items = [1,2,3];

items.reverse();

console.log(items);
[3,2,1]