typedArray.values() returns a new iterator that gives you the elements of the typed array, from index 0 to the end. It is what a for...of loop and the spread syntax [...ta] use behind the scenes: ta.values and ta[Symbol.iterator] are the very same function. Each value comes out exactly as the type stores it, so a Float32Array gives single-precision numbers and a BigInt64Array gives BigInts.
Remember
typedArray.values() → iterator of elements
new Uint8Array([4, 5]).values() → 4, 5
for (const v of ta) { } // calls values() for you
[...ta.values()] → normal Array of the values
ta.values === ta[Symbol.iterator] // true
Syntax
values() takes no arguments. Call it on any typed array.
JavaScript
typedArray.values()
Call
What it does
ta.values()
Get an iterator over the elements, in index order.
[...ta.values()]
Spread the elements into a new normal Array.
for (const v of ta.values())
Loop over the elements. Writing for (const v of ta) does the same.
Built into JavaScript since ES2015 on all 11 typed array types. values() is the default iterator, so for...of, spread, and Array.from(ta) all use it automatically.
Library declarations
JavaScript
TypedArray.prototype.values() // returns an Array Iterator
// iterator.next() -> { value: element, done: false }
// after the last element -> { value: undefined, done: true }
// TypedArray.prototype[Symbol.iterator] === TypedArray.prototype.values
Parameters
Parameter
Description
(none)
values() has no parameters. Extra arguments are ignored.
Return Value
Return Value
Description
Array Iterator
A new iterator object. Each next() call returns the next element as { value, done }. Values have the element type: numbers, or BigInts for BigInt64Array and BigUint64Array.
JavaScript Examples
Example 1 — Add Up Prices With for...of
Prices in cents are stored in a Uint16Array. A for...of loop over values() visits each price once.
JavaScript
const prices = new Uint16Array([120, 45, 300, 15]);
let total = 0;
for (const price of prices.values()) {
total += price;
}
console.log('items: ' + prices.length); // items: 4
console.log('total: ' + total); // total: 480
Spread runs the iterator.[...ratios.values()] pulls out all three elements and puts them in a brand-new normal Array.
Values keep their stored form. Float32Array could not store 0.1 exactly, so the spread copy shows 0.10000000149011612. Spreading does not undo that rounding.
Array methods are back. The typed array has no concat property at all, but the plain Array does, and joining it with one more number gives length 4.
Compatibility
Browser & Runtime Support
TypedArray.prototype.values() is part of ES2015 (ES6), together with typed arrays, iterators, and for...of.
✓ Baseline · ES2015
TypedArray.prototype.values()
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
values()Excellent
Bottom line: Safe everywhere modern JavaScript runs. Internet Explorer 10 and 11 have typed arrays but no iterators, so there you would need a plain for loop with an index.
Frequently Asked Questions
An iterator that produces the elements one by one, from index 0 to the last index. Read it with for...of, spread it with [...ta.values()], or collect it with Array.from().
Yes. ta.values === ta[Symbol.iterator] is true; they are one function stored under two names. That is why for (const v of ta) gives exactly the same values as for (const v of ta.values()).
No. The iterator reads each element when you ask for it, so changes made to later elements before the loop reaches them are seen. Copy first with slice() if you need a fixed snapshot.
Use [...ta.values()], [...ta], or Array.from(ta). The result is a regular Array, so methods that typed arrays lack, such as push() and concat(), work again.
BigInt values such as 5n, because the iterator returns elements exactly as the type stores them. Convert with String(v) or Number(v) when you want plain digits in your output.