JavaScript Array reverse() Method

Beginner
⏱️ 7 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Mutates

What You’ll Learn

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

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.

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.

📝 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.
  • str.split("").reverse().join("") — reverse ASCII string.
  • arr.toReversed() — non-mutating (ES2023).

⚡ Quick Reference

GoalCode
Reverse in placearr.reverse()
Reversed copy[...arr].reverse()
Non-mutating (modern)arr.toReversed()
Reverse string charss.split("").reverse().join("")
Mutates array?Yes

📋 reverse() vs toReversed() vs slice() vs reduceRight()

Choose in-place flip vs copy vs fold-from-end patterns.

reverse
mutates

In place

toReversed
new array

ES2023

slice + reverse
copy

Classic pattern

reduceRight
fold ←

Custom build

Examples Gallery

Open DevTools Console (F12) or use Try-it labs. Example N maps to ?tryit=N.

📚 Getting Started

Flip element order in the same array.

Example 1 — Reverse an Array In Place

Call reverse() on a number array and log the result.

JavaScript
const numbers = [1, 2, 3, 4, 5];

numbers.reverse();

console.log(numbers);
// [5, 4, 3, 2, 1]
Try It Yourself

How It Works

The same numbers variable now points to reversed content. Length stays 5.

Example 2 — Return Value Is the Same Array

reverse() returns the mutated array reference.

JavaScript
const colors = ["red", "green", "blue"];

const result = colors.reverse();

console.log(result === colors);
// true

console.log(result);
// ["blue", "green", "red"]
Try It Yourself

How It Works

Assigning the return value is optional—colors is already reversed after the call.

📈 Practical Patterns

Preserve originals, strings, and palindromes.

Example 3 — Reverse a Copy, Keep the Original

Spread into a new array before calling reverse().

JavaScript
const original = [1, 2, 3, 4, 5];

const reversed = [...original].reverse();

console.log("original:", original);
// [1, 2, 3, 4, 5]

console.log("reversed:", reversed);
// [5, 4, 3, 2, 1]
Try It Yourself

How It Works

The spread creates a shallow copy. Reversing the copy leaves original untouched.

Example 4 — Reverse Characters in a String

Convert to array, reverse, join back—works well for simple ASCII text.

JavaScript
const greeting = "Hello";

const reversed = greeting.split("").reverse().join("");

console.log(reversed);
// "olleH"
Try It Yourself

How It Works

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).

JavaScript
function isPalindrome(word) {
  const normalized = word.toLowerCase();
  const reversed = normalized.split("").reverse().join("");
  return normalized === reversed;
}

console.log(isPalindrome("level"));
// true

console.log(isPalindrome("hello"));
// false
Try It Yourself

How It Works

Palindromes read the same forward and backward. This pattern is a classic teaching use of reverse() on char arrays.

🚀 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.

📝 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.

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 Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · 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.

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.

💡 Best Practices

✅ Do

  • Copy with [...arr] when immutability matters
  • Use toReversed() in modern code for clarity
  • Remember all aliases see the reversed array
  • Chain after copy: [...items].reverse().join()
  • Normalize case for palindrome checks

❌ Don’t

  • Reverse shared arrays without telling teammates
  • Assume reverse returns a new array
  • Rely on split/reverse for complex Unicode emoji
  • Reverse then expect old order elsewhere
  • Use reverse when sort with comparator fits better

Key Takeaways

Knowledge Unlocked

Five things to remember about Array.reverse()

Flip element order inside the same array.

5
Core concepts
02

Mutates

In place.

Side effect
🔁 03

Same ref

Return value.

Output
📋 04

Copy

Spread first.

Pattern
abc 05

Strings

split + join.

Trick

❓ Frequently Asked Questions

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.

Continue to shift()

Learn how to remove and return the first element from an array.

shift() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful