JavaScript Array reverse() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

Array.prototype.reverse() flips the order of elements in place — first becomes last, last becomes first. It returns the same array reference. Need the original order kept? Copy first, or use toReversed().

Remember
array.reverse()

[1, 2, 3].reverse()  →  [3, 2, 1]

mutates the array  ✓
returns same array ✓

keep original? → copy first, then reverse
immutable alt  → toReversed() (ES2023)

Syntax

Call array.reverse. Start with this line.

JavaScript
array.reverse()
CallWhat it does
array.reverse()Primary signature.
array.reverse(...)Call with the arguments your case needs.

Built into JavaScript. Call reverse(...) on an array instance — no import required.

Library declarations
JavaScript
array.reverse()

Parameters

ParameterDescription
ArrayRequired. Target whose order will flip

Return Value

Return ValueDescription
*Same array reference, now reversed

JavaScript Examples

Example 1 — Reverse In Place

Call reverse() on a number array and log the mutated 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

  1. Start with five numbers. Indexes run 0 … 4.
  2. Call reverse. Ends swap toward the middle: 1↔5, 2↔4; 3 stays.
  3. Same variable. numbers now holds [5, 4, 3, 2, 1] — length is unchanged.
  4. No new array. This is mutation, not a copy.

Example 2 — Copy First, Keep the Original

Copy with slice(), then reverse the copy so the source stays safe.

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

const reversed = original.slice().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

  1. Make a shallow copy. slice() returns a new array with the same values.
  2. Reverse only the copy. reverse() mutates that new array, not original.
  3. Compare both. Source stays [1, 2, 3, 4, 5]; copy is flipped.
  4. Alternative. [...original].reverse() does the same job with spread.

Example 3 — Reverse Characters in a String

Strings are not arrays — split, reverse, then join for simple text.

JavaScript
const greeting = "Hello";

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

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

How It Works

  1. Split into characters. split("") → ["H","e","l","l","o"].
  2. Reverse the array. Order becomes ["o","l","l","e","H"].
  3. Join back. join("") rebuilds the string "olleH".
  4. Caveat. Fine for ASCII; emoji and some Unicode need grapheme-aware tools.

Browser & Runtime Support

Array.prototype.reverse() has been part of JavaScript since ES3 / JavaScript 1.2 — long before modern array helpers.

✓ Baseline · ES3

Array.prototype.reverse()

Supported in every major browser (including Internet Explorer) and all Node.js versions. No polyfill required.

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() Excellent

Bottom line: Safe everywhere. For an immutable reverse in modern engines, prefer toReversed() (ES2023) when you cannot mutate the source.

Frequently Asked Questions

reverse() flips 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—or use toReversed() when available.
The same array reference, now reversed. Assigning the return value is optional because 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 emoji and complex Unicode, use grapheme-aware tools instead of naive split.
reverse() has been available since JavaScript 1.2 / ES3. It works in every browser, including very old environments.

Next: shift()

Learn how to remove the first element from an array and get its value.

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.

10 people found this page helpful