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.