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'];
sandwiches.reverse();

// returns ["chicken salad", "italian", "tuna", "turkey"]
console.log(sandwiches);

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