Skip to main content Accessibility Feedback

Reversing the order of an array with vanilla JavaScript

It’s incredibly easy to reverse the order of an array’s values with vanilla JavaScript, thanks to the Array.reverse() method.

var sandwiches = ['turkey', 'tuna', 'italian', 'chicken salad'];

// returns ["chicken salad", "italian", "tuna", "turkey"]

This works in all moderns browsers and back to at least IE6.

🚀 Make 2018 the year you master JavaScript! My pocket guides and mini courses are short, focused, and made for beginners. You can do this!

Have any questions or comments about this post? Email me at or contact me on Twitter at @ChrisFerdinandi.

Get Daily Developer Tips