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()
Call
What 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
Parameter
Description
(none)
reverse() has no parameters. Extra arguments are ignored.
Return Value
Return Value
Description
TypedArray
The 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
Copy, then flip.slice() with no arguments copies all three readings into a new Int16Array. Only that copy is reversed.
The type is kept. The result is still an Int16Array, so negative numbers such as -5 keep working as before.
Two flips cancel out. Calling reverse() twice on readings puts every element back where it started.
Compatibility
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 ChromeAll modern versions
Full support
Mozilla FirefoxAll modern versions
Full support
Apple SafariAll modern versions
Full support
Microsoft EdgeAll modern versions
Full support
Node.jsAll current releases
Supported
DenoAll releases
Supported
Internet ExplorerIE 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.