JavaScript TypedArray toReversed() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
ES2023

Definition

typedArray.toReversed() is the copying version of reverse(). It returns a new typed array of the same type with the elements in reverse order, and the original is left exactly as it was. The new array has its own ArrayBuffer, so changing one never changes the other. It was added in ES2023, together with toSorted() and with().

Remember
typedArray.toReversed()   → NEW typed array, reversed

const a = new Uint8Array([1, 2, 3]);
const b = a.toReversed();    // b: 3 2 1
a                            // still 1 2 3
b.buffer !== a.buffer        // true

reverse()    → changes the original
toReversed() → leaves it alone

Syntax

toReversed() takes no arguments. Call it on any typed array.

JavaScript
typedArray.toReversed()
CallWhat it does
ta.toReversed()Get a new typed array with the elements in reverse order.
ta.toReversed().join(" ")Reverse a copy and turn it into text for printing.
for (const v of ta.toReversed())Walk the data from the last element to the first without changing it.

Added in ES2023 for all 11 typed array types. Older browsers do not have it; use ta.slice().reverse() there.

Library declarations
JavaScript
TypedArray.prototype.toReversed()   // returns a new typed array

// same type and length as the original, new ArrayBuffer
// the original typed array is not modified

Parameters

ParameterDescription
(none)toReversed() has no parameters. Extra arguments are ignored.

Return Value

Return ValueDescription
TypedArrayA new typed array of the same type and length, in reverse order. It does not share memory with the original.

JavaScript Examples

Example 1 — Reverse Without Touching the Original

Four steps of a path are stored as bytes. We want the way back, but we also want to keep the way forward.

JavaScript
const forward = new Uint8Array([1, 2, 3, 4]);
const back = forward.toReversed();

console.log(forward.join(' '));    // 1 2 3 4
console.log(back.join(' '));       // 4 3 2 1
console.log(back === forward);     // false
Try It Yourself

How It Works

  1. The source is read only. forward.toReversed() only reads the four bytes. Printing forward still gives 1 2 3 4.
  2. The copy holds the new order. The new array starts with 4 and ends with 1, so it is the path back.
  3. Two different objects. Unlike reverse(), the result is a separate object, so back === forward is false.

Example 2 — Same Type, Separate Memory

The copy is another Uint16Array with its own buffer. Changing it later does not leak back into the original.

JavaScript
const volumes = new Uint16Array([300, 500, 700]);
const flipped = volumes.toReversed();

console.log(flipped.constructor.name);           // Uint16Array
console.log(flipped.buffer === volumes.buffer);  // false

flipped[0] = 1;
console.log(volumes.join(' '));                  // 300 500 700
console.log(flipped.join(' '));                  // 1 500 300
Try It Yourself

How It Works

  1. The element type is kept. constructor.name prints Uint16Array. You never get a plain Array from this method.
  2. A brand-new buffer. The two buffer properties are different objects, so the bytes are not shared between the arrays.
  3. Writing to the copy is safe. Setting flipped[0] = 1 changes only the copy. The volumes array keeps 300 500 700.

Example 3 — Read the Newest Value First

A history of daily visitor counts is stored oldest first. A loop over the reversed copy shows the newest day first.

JavaScript
const history = new Uint16Array([120, 135, 150]);

for (const count of history.toReversed()) {
  console.log('visitors: ' + count);
}

console.log(history.at(-1));                       // 150
console.log(history.toReversed().toReversed().join(' '));  // 120 135 150
Try It Yourself

How It Works

  1. A loop over the copy. for...of walks the reversed copy, so it prints 150 first and 120 last.
  2. The history stays oldest first. history.at(-1) still returns 150, because the last element of the original did not move.
  3. Reverse twice, get home. Reversing a copy of a copy gives the first order again, here 120 135 150.

Browser & Runtime Support

TypedArray.prototype.toReversed() was added in ES2023, together with toSorted() and with().

✓ Baseline · ES2023

TypedArray.prototype.toReversed()

Supported in recent versions of Chrome, Edge, Firefox, Safari, and Node.js.

93% Recent browsers only
Google Chrome Chrome 110 and newer
Full support
Mozilla Firefox Firefox 115 and newer
Full support
Apple Safari Safari 16 and newer
Full support
Microsoft Edge Edge 110 and newer
Full support
Node.js Node.js 20 and newer
Supported
Deno Recent versions
Supported
Internet Explorer No support
Not supported
toReversed() Recent browsers

Bottom line: Use it in recent browsers and Node.js 20 or newer. For older ones, write ta.slice().reverse(), which does the same job.

Frequently Asked Questions

reverse() flips the original and returns it. toReversed() builds a new typed array in reverse order and leaves the original alone.
It is an ES2023 method: Chrome 110, Edge 110, Firefox 115, Safari 16, and Node.js 20. Older versions throw a TypeError, so use slice().reverse() there.
No. It returns a typed array of the same type as the original, for example a Uint8Array stays a Uint8Array.
No. The copy has its own ArrayBuffer, so writing to one array never changes the other.
Yes. It returns a new empty typed array of the same type, with length 0.

Next: toSorted()

Get a sorted copy of the typed array, in numeric order, and keep the original.

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

11 people found this page helpful