JavaScript TypedArray values() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
ES2015

Definition

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

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

Return Value

Return ValueDescription
Array IteratorA 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
Try It Yourself

How It Works

  1. The loop variable is the stored number. Each turn gives price the next element of the Uint16Array: 120, 45, 300, and finally 15. No index is needed.
  2. A normal number to add up. Each element arrives as an ordinary JavaScript number, so total can grow past what one Uint16 could hold without wrapping.
  3. Four elements, one sum. The loop ends after the fourth element, and 120 + 45 + 300 + 15 prints as a total of 480.

Example 2 — The Iterator Sees Later Changes

values() does not take a snapshot. Here we change an element after the iterator was created but before it got there.

JavaScript
const pixels = new Uint8Array([10, 20, 30]);
const it = pixels.values();

console.log(it.next().value);  // 10
pixels[1] = 99;
console.log(it.next().value);  // 99
console.log(it.next().value);  // 30
console.log(it.next().done);   // true
Try It Yourself

How It Works

  1. The first read happens right away. The first next() reads index 0 and returns 10. Index 1 has not been read yet.
  2. Changing a later element. pixels[1] = 99 overwrites the second byte while the iterator is paused, so the next read returns 99, not 20.
  3. Finishing the walk. The third read gives 30, and one more next() reports done: true because all three elements are used up.

Example 3 — Spread the Values Into a Normal Array

Typed arrays have no concat(). Spreading values() gives a normal Array, which has it. Notice the Float32 value.

JavaScript
const ratios = new Float32Array([0.5, 0.1, 2]);

const plain = [...ratios.values()];
console.log(Array.isArray(plain));      // true
console.log(plain.join(' | '));         // 0.5 | 0.10000000149011612 | 2
console.log(typeof ratios.concat);      // undefined
console.log(plain.concat([7]).length);  // 4
Try It Yourself

How It Works

  1. Spread runs the iterator. [...ratios.values()] pulls out all three elements and puts them in a brand-new normal Array.
  2. 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.
  3. 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.

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 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
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.

Next: with()

Get a copy of the typed array with one element replaced, leaving the original as it is.

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