JavaScript TypedArray reverse() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
ES2015

Definition

typedArray.reverse() turns the typed array around in place: the first element becomes the last, the second becomes the second-to-last, and so on. It returns the same typed array, not a copy. A typed array is only a view on an ArrayBuffer, so the bytes of the buffer are swapped too, but only the part that this view covers. When you need the original order to stay, make a copy first or use toReversed().

Remember
typedArray.reverse()   → same array, reversed in place

new Uint8Array([1, 2, 3]).reverse()   → 3 2 1
ta.reverse() === ta                   → true

copy first:  ta.slice().reverse()     // original stays
ES2023:      ta.toReversed()          // new array

Syntax

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

JavaScript
typedArray.reverse()
CallWhat it does
ta.reverse()Flip the elements in place and get the same typed array back.
ta.slice().reverse()Copy first, then flip the copy. The original keeps its order.
ta.reverse().join(" ")Chain: reverse, then turn the result into text.

Built into JavaScript since ES2015 on all 11 typed array types. It works the same for numbers and for BigInts.

Library declarations
JavaScript
TypedArray.prototype.reverse()   // returns the same typed array

// mutates the view and the bytes of the buffer it covers
// empty or one-element arrays: nothing visible changes

Parameters

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

Return Value

Return ValueDescription
TypedArrayThe same typed array object, now in reverse order. ta.reverse() === ta is true. It is the same idea as Array reverse().

JavaScript Examples

Example 1 — Reverse a Uint8Array in Place

Five lap numbers are stored in a Uint8Array. We flip them and check that the method gave back the very same array.

JavaScript
const laps = new Uint8Array([1, 2, 3, 4, 5]);
const result = laps.reverse();

console.log(laps.join(' '));                       // 5 4 3 2 1
console.log(result === laps);                      // true
console.log(new Uint8Array(0).reverse().length);   // 0
Try It Yourself

How It Works

  1. The array itself is flipped. After laps.reverse() the element at index 0 holds 5 and the one at index 4 holds 1. No second array was created.
  2. The return value is the original. result === laps prints true, so result and laps are two names for one object.
  3. Nothing to flip is fine. A typed array with zero elements has nothing to swap. The call works and the length stays 0.

Example 2 — Reversing a View Changes the Shared Buffer

A small packet has a header byte, four payload bytes, and a footer byte. A second view covers only the payload, so only those bytes get flipped.

JavaScript
const buffer = new ArrayBuffer(6);
const packet = new Uint8Array(buffer);
packet.set([1, 2, 3, 4, 5, 6]);

const payload = new Uint8Array(buffer, 1, 4);
payload.reverse();

console.log(payload.join(' '));   // 5 4 3 2
console.log(packet.join(' '));    // 1 5 4 3 2 6
Try It Yourself

How It Works

  1. Two views, one buffer. packet sees all six bytes. payload starts at byte 1 and is 4 elements long, so it covers the middle four bytes only.
  2. Only the view is reversed. payload.reverse() swaps 2, 3, 4, 5 into 5, 4, 3, 2 inside that window. The first and last bytes are outside the view.
  3. The full view shows the change. Printing packet gives 1 5 4 3 2 6, because both views read the same memory.

Example 3 — Reverse a Copy and Keep the Original

Sensor readings, some of them negative, sit in an Int16Array. We want them newest first without touching the stored order.

JavaScript
const readings = new Int16Array([-5, 12, 30]);

const newestFirst = readings.slice().reverse();
console.log(readings.join(' '));                  // -5 12 30
console.log(newestFirst.join(' '));               // 30 12 -5
console.log(newestFirst instanceof Int16Array);   // true

readings.reverse().reverse();
console.log(readings.join(' '));                  // -5 12 30
Try It Yourself

How It Works

  1. Copy, then flip. slice() with no arguments copies all three readings into a new Int16Array. Only that copy is reversed.
  2. The type is kept. The result is still an Int16Array, so negative numbers such as -5 keep working as before.
  3. Two flips cancel out. Calling reverse() twice on readings puts every element back where it started.

Browser & Runtime Support

TypedArray.prototype.reverse() is part of ES2015 (ES6), together with typed arrays and the other array-like methods.

✓ Baseline · ES2015

TypedArray.prototype.reverse()

Supported in every modern browser, plus Node.js, Deno, and Bun.

98% Modern browser support
Google Chrome All modern versions
Full support
Mozilla Firefox All modern versions
Full support
Apple Safari All modern versions
Full support
Microsoft Edge All modern versions
Full support
Node.js All current releases
Supported
Deno All releases
Supported
Internet Explorer IE 10 and 11 have typed arrays, but not this method
Not supported
reverse() Excellent

Bottom line: Safe everywhere modern JavaScript runs. Internet Explorer 10 and 11 have typed arrays but not this method, so reverse with a plain for loop there.

Frequently Asked Questions

Yes. It flips the elements in place and returns the same typed array. Copy first with slice(), or use toReversed(), when the original order must stay.
The same typed array object. That is why ta.reverse() === ta is true and why you can chain more methods after it.
Yes. The elements live in the buffer, so the bytes covered by this view are rearranged. Other views on the same buffer see the new order for those bytes.
The idea is the same. The typed array keeps its length and its element type, so the result is never a plain array and the values never change type.
Use ta.slice().reverse() in any browser, or ta.toReversed() in ES2023 browsers. Both give you a new typed array of the same type.

Next: set()

Copy a whole typed array, or another array, into it starting at a chosen offset.

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