The reverse() method flips an array in place so the first element becomes last and vice versa. This tutorial covers syntax, five examples, copying before reverse, string reversal, palindrome checks, and comparison with toReversed().
01
Syntax
arr.reverse()
02
In place
Mutates
03
Returns
Same array
04
Copy first
[...arr]
05
Strings
split + join
06
ES3
Universal
Fundamentals
Introduction
Need to walk a list backward, undo a stack visually, or reverse characters in a word? reverse() swaps element positions so index 0 and index length - 1 trade places, then the next pair inward, until the whole array is flipped.
Because it mutates the original array, be careful when other variables reference the same array—they will see the reversed order too.
Concept
Understanding the reverse() Method
array.reverse() rearranges elements within the existing array object. No new array is allocated. The method returns a reference to that same array (now reversed), which enables chaining like arr.reverse().join("-").
To keep the original order, copy first: [...arr].reverse() or arr.slice().reverse(). Modern JavaScript also offers non-mutating arr.toReversed() (ES2023).
💡
Beginner Tip
Sorting with sort() also mutates arrays. If you sort then reverse, both operations change the same underlying list—plan copies when you need the pre-sort order later.
Foundation
📝 Syntax
General form of Array.prototype.reverse:
JavaScript
array.reverse()
Parameters
None.
Return value
The same array reference, with elements reversed.
Side effects
Mutates element order in the array.
Common patterns
arr.reverse() — flip in place.
[...arr].reverse() — reversed copy, original safe.
split("") makes a character array. After reverse and join, you get a flipped string. Emoji and some Unicode sequences need grapheme-aware tools beyond this beginner pattern.
Example 5 — Check a Palindrome
Compare a word with its reversed form (case-insensitive).
Palindromes read the same forward and backward. This pattern is a classic teaching use of reverse() on char arrays.
Applications
🚀 Common Use Cases
Display newest first — reverse a fetched list for UI.
Undo stack inspection — walk items backward.
String tricks — char reverse and palindrome tests.
Algorithm practice — two-pointer problems on reversed copies.
Sort companion — flip ascending to descending (prefer sort comparator when possible).
Immutable UI state — use copy or toReversed().
🧠 How reverse() Runs
1
Set pointers
Start at index 0 and length - 1.
Setup
2
Swap pairs
Exchange outer elements, move inward.
Swap
3
Stop at middle
When pointers meet, done.
Finish
4
🔄
Return same array
Reference to mutated, reversed array.
Important
📝 Notes
Mutates element order in the array.
Returns the same array reference.
Copy with spread/slice when the original order must stay.
toReversed() (ES2023) is the non-mutating alternative.
String reverse via split/reverse/join is for simple text.
Shared references all see the reversal after mutation.
ES3—supported everywhere JavaScript runs.
Compatibility
Browser & Runtime Support
Array.prototype.reverse() has been available since JavaScript 1.2 / ES3. Non-mutating toReversed() requires ES2023.
✓ Baseline · ES3
Array.prototype.reverse()
Supported in every browser ever shipped with JavaScript arrays, including Internet Explorer 3+, and all Node.js versions.
100%Universal support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
Array.reverse()Universal
Bottom line: Safe to use in any environment. Use toReversed() when you need a copy without mutation in modern browsers.
Wrap Up
Conclusion
reverse() flips array order in one in-place operation. Copy first or use toReversed() when the original sequence must remain. It also powers classic string and palindrome patterns via split and join.
Next, learn shift() to remove the first element from an array.
reverse() reverses the order of elements in the array in place—the first becomes last and the last becomes first. It returns a reference to the same array.
Yes. reverse() changes the array you call it on. To keep the original order, copy first with spread or slice, then reverse the copy.
The same array reference, now reversed. You can chain or assign it, but the original variable already points to the mutated array.
reverse() mutates the source array. toReversed() (ES2023) returns a new reversed array and leaves the original unchanged.
Strings are not arrays. Convert with split(''), reverse the array, then join('') back into a string. For Unicode-aware reversal, use modern string APIs instead of split on complex characters.
reverse() has been available since JavaScript 1.2 / ES3. It works in every browser including very old environments.
Did you know?
Calling reverse() twice restores the original order (if no other mutations happened in between). It is its own inverse for element sequence.