JavaScript TypedArray Methods

About This Index
This page is the JavaScript TypedArray Methods index for the tutorial track. Each row links to a full guide with syntax, three runnable examples, browser notes, and FAQs.
Learn what a typed array is on /js/typed-array. Use this page when you need a specific method such as at(), subarray(), or toSorted().
Every typed array type, such as Uint8Array, Int16Array, or Float32Array, shares the same methods. They are inherited from a hidden parent class called TypedArray, which is why this tutorial writes TypedArray.from() for what you call as Uint8Array.from().
How to Call a TypedArray Method
Instance methods use a dot on the typed array. The two static methods are called on the type you want to create:
const bytes = new Uint8Array([3, 1, 2]);
// Instance methods (every typed array has them)
bytes.at(-1); // 2
bytes.includes(3); // true
bytes.sort(); // in place: 1, 2, 3 (numeric order)
bytes.toReversed(); // new copy: 3, 2, 1 (ES2023)
for (const v of bytes) {} // uses [Symbol.iterator]() for you
// Static methods (on the type you want)
Uint8Array.from([1, 2, 3]);
Int16Array.of(-1, 0, 1); JavaScript TypedArray Methods Table
All method guides in this JavaScript tutorial series (34 tutorials), grouped by what they do.
Create typed arrays
2 methodsStatic methods on a concrete constructor such as Uint8Array or Int16Array. They build a brand-new typed array.
| Method | Description | Tutorial |
|---|---|---|
TypedArray.from() | Create a new typed array from an array, an iterable, or an array-like object, with an optional map function. | Open |
TypedArray.of() | Create a new typed array from a list of arguments, such as Int16Array.of(1, -2, 3). | Open |
Read and find
8 methodsRead one element, or search for a value or for the first or last element that passes a test.
| Method | Description | Tutorial |
|---|---|---|
at() | Read the element at an index. Negative numbers count back from the end (ES2022). | Open |
find() | Return the first element that passes a test, or undefined. | Open |
findIndex() | Return the index of the first element that passes a test, or -1. | Open |
findLast() | Return the last element that passes a test, searching from the end (ES2023). | Open |
findLastIndex() | Return the index of the last element that passes a test, or -1 (ES2023). | Open |
includes() | Check whether a value is in the typed array. It can also find NaN. | Open |
indexOf() | Return the first index of a value, or -1 when it is not there. | Open |
lastIndexOf() | Return the last index of a value, or -1 when it is not there. | Open |
Loop, test, and transform
7 methodsRun a callback for each element. The callback gets (value, index, array). map() and filter() return a new typed array of the same type.
| Method | Description | Tutorial |
|---|---|---|
every() | Check whether every element passes a test. | Open |
some() | Check whether at least one element passes a test. | Open |
forEach() | Run a function once for each element, together with its index. | Open |
filter() | Keep the elements that pass a test, in a new typed array of the same type. | Open |
map() | Change every element and get a new typed array of the same type. Results are converted to that type. | Open |
reduce() | Combine all elements into one value, from left to right. | Open |
reduceRight() | Combine all elements into one value, from right to left. | Open |
Copy, fill, and views
5 methodsCopy values in, copy a part out, make a view that shares memory, or overwrite a range with one value.
| Method | Description | Tutorial |
|---|---|---|
set() | Copy values from an array or another typed array into this one, at an offset. | Open |
subarray() | Get a view of part of the typed array that shares the same memory (no copy). | Open |
slice() | Copy part of the typed array into a new, independent typed array. | Open |
fill() | Set every element, or a range of elements, to one value. | Open |
copyWithin() | Copy a range of elements to another position inside the same typed array. | Open |
Reorder in place
2 methodsChange the order of the elements inside the same typed array. sort() is numeric by default.
Make a changed copy (ES2023)
3 methodsNon-mutating versions that return a new typed array and leave the original exactly as it was.
| Method | Description | Tutorial |
|---|---|---|
toReversed() | Return a reversed copy and leave the original unchanged (ES2023). | Open |
toSorted() | Return a sorted copy and leave the original unchanged (ES2023). | Open |
with() | Return a copy with one element replaced (ES2023). | Open |
Join and convert to text
3 methodsTurn the numbers into one string, with a separator or with locale formatting.
| Method | Description | Tutorial |
|---|---|---|
join() | Join all elements into one string with a separator of your choice. | Open |
toString() | Turn the typed array into a comma-separated string. | Open |
toLocaleString() | Turn the elements into a string with locale number formatting, such as 1,234.5. | Open |
Iterate
4 methodsGet an iterator of indexes, values, or [index, value] pairs for for...of loops, spread, and Array.from().
Constructors and Properties
Constructors are used with new; properties are read with a dot and no parentheses. Replace Uint8Array with any of the 11 types. They are listed here for quick reference.
| Member | What it gives you |
|---|---|
new Uint8Array(length) | A typed array with length elements, all set to 0. |
new Uint8Array(arrayOrIterable) | Copy numbers from an array or any iterable. Each value is converted to the element type. |
new Uint8Array(buffer, byteOffset, length) | A view on an existing ArrayBuffer, starting byteOffset bytes in. |
ta.length | Number of elements. It never changes, unless the view follows a resizable ArrayBuffer (ES2024). |
ta.byteLength | Size in bytes: length times BYTES_PER_ELEMENT. |
ta.byteOffset | Where the view starts inside its buffer, in bytes. |
ta.buffer | The ArrayBuffer that really holds the bytes. |
Uint8Array.BYTES_PER_ELEMENT | Bytes per element: 1, 2, 4, or 8. Also readable on every instance. |
What Typed Arrays Do Not Have
Some Array methods do not exist on typed arrays. Calling them throws a TypeError because the property is undefined.
| Array method | Why it is missing | What to do instead |
|---|---|---|
push() pop() shift() unshift() | The length is fixed when the typed array is created. | Create a bigger typed array and copy the old values in with set(). |
splice() toSpliced() | Both would need a different length. | Build the result from slice() pieces and set(). |
concat() | Not defined on typed arrays. | new Uint8Array(a.length + b.length), then set(a) and set(b, a.length). |
flat() flatMap() | A typed array only holds numbers, never nested arrays. | Use map(), or convert with Array.from() first. |
Frequently Asked Questions
Start with TypedArray.from()
Learn the most flexible way to create a typed array from an array, a string of digits, or any iterable.
14 people found this page helpful
