How to reverse an array in JavaScript

Reversing the order of array elements is useful for displaying data in descending order, implementing undo functionality, or creating reverse chronological lists in JavaScript applications. With over 25 years of experience in software development and as the creator of CoreUI, I’ve implemented array reversal in components like activity feeds, breadcrumb navigation, and timeline displays where the most recent items need to appear first. From my extensive expertise, the most straightforward and efficient solution is using the built-in reverse() method, which flips the array order in place. This method is simple, fast, and specifically designed for this exact use case.

Use the reverse() method to flip the order of elements in an array.

const numbers = [1, 2, 3, 4, 5]
numbers.reverse()
// Result: [5, 4, 3, 2, 1]

The reverse() method reverses the elements of an array in place, meaning it modifies the original array and returns a reference to the same array. In this example, numbers.reverse() changes the array from [1, 2, 3, 4, 5] to [5, 4, 3, 2, 1], with the last element becoming the first and vice versa. The method doesn’t create a new array but modifies the existing one, which makes it memory efficient but means the original order is lost.

Best Practice Note:

This is the same approach we use in CoreUI components for creating reverse-ordered lists and implementing chronological data display. To avoid mutating the original array, create a copy first: [...array].reverse(). For complex sorting needs, combine with sort(): array.sort().reverse() gives you descending alphabetical order. The reverse() method is the fastest way to flip array order.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author