JavaScript TypedArray [Symbol.iterator]() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
ES2015

Definition

typedArray[Symbol.iterator]() returns an iterator over the elements of the typed array. You rarely call it by hand: for...of, the spread syntax [...ta], Array.from(ta), and destructuring such as const [a, b] = ta all call it for you. It is the same function as values(). Call it yourself to read elements one at a time with next().

Remember
ta[Symbol.iterator]()   → iterator of elements

ta[Symbol.iterator] === ta.values   // true

for (const v of ta) { }   // calls ta[Symbol.iterator]()
[...ta]                   // calls it too
const [a, b] = ta;        // and so does destructuring

Syntax

Use square brackets, because the key is the symbol Symbol.iterator, not a normal name.

JavaScript
typedArray[Symbol.iterator]()
CallWhat it does
ta[Symbol.iterator]()Get an iterator over the elements, exactly like ta.values().
ta[Symbol.iterator]().next()Read the first element as { value, done }.
typeof x[Symbol.iterator]"function" when x can be used in for...of.

Built into JavaScript since ES2015 on all 11 typed array types. This method is what makes a typed array iterable.

Library declarations
JavaScript
TypedArray.prototype[Symbol.iterator]()   // returns an Array Iterator

// TypedArray.prototype[Symbol.iterator] === TypedArray.prototype.values
// iterator.next() -> { value: element, done: false }
// after the last element -> { value: undefined, done: true }

Parameters

ParameterDescription
(none)[Symbol.iterator]() has no parameters. Extra arguments are ignored.

Return Value

Return ValueDescription
Array IteratorA new iterator object over the elements, the same as values() returns. Values are numbers, or BigInts on the two BigInt types.

JavaScript Examples

Example 1 — Read a Small Packet Step by Step

A tiny message format: the first byte says how many letters follow. Calling [Symbol.iterator]() ourselves lets us pull exactly that many bytes.

JavaScript
const packet = new Uint8Array([3, 65, 66, 67]);
const reader = packet[Symbol.iterator]();

const count = reader.next().value;
let text = '';
for (let n = 0; n < count; n++) {
  text += String.fromCharCode(reader.next().value);
}

console.log('length byte: ' + count);
console.log('text: ' + text);
console.log(reader.next().done);
Try It Yourself

How It Works

  1. The first next() reads the header. reader.next().value takes byte 0, the number 3, which says three letters follow.
  2. The same iterator continues. Each further next() picks up where the last one stopped, so the loop reads bytes 65, 66, and 67 and turns them into A, B, and C.
  3. Nothing is left over. All four bytes were consumed, so one more next() reports done as true.

Example 2 — It Is What for...of Calls

We walk an Int32Array twice: once by calling [Symbol.iterator]() ourselves and once with a normal for...of loop.

JavaScript
const grid = new Int32Array([7, -7, 70]);

console.log(grid[Symbol.iterator] === grid.values);  // true

const bySymbol = [];
const it = grid[Symbol.iterator]();
for (let r = it.next(); !r.done; r = it.next()) bySymbol.push(r.value);

const byLoop = [];
for (const v of grid) byLoop.push(v);

console.log(bySymbol.join(' '));
console.log(byLoop.join(' '));
Try It Yourself

How It Works

  1. One function, two names. The strict equality check proves that grid[Symbol.iterator] and grid.values are the very same function object.
  2. The manual loop. The classic for loop calls next() until r.done is true and pushes every r.value into bySymbol.
  3. for...of does the same work. for (const v of grid) calls [Symbol.iterator]() behind the scenes, so both lists print the identical text 7 -7 70.

Example 3 — Make Your Own Object Iterable

A playlist stores song IDs in a Uint16Array. Its own [Symbol.iterator]() hands back the typed array's iterator, so spread and destructuring work on it.

JavaScript
const playlist = {
  ids: new Uint16Array([501, 502, 503]),
  [Symbol.iterator]() {
    return this.ids[Symbol.iterator]();
  }
};

console.log([...playlist].join(', '));  // 501, 502, 503
const [first, second] = playlist;
console.log(first + second);            // 1003
console.log(typeof new Float32Array(1)[Symbol.iterator]);  // function
Try It Yourself

How It Works

  1. A method with a symbol name. The object defines [Symbol.iterator]() and simply returns the iterator of its ids typed array.
  2. Spread and destructuring now work. [...playlist] lists all three IDs, and const [first, second] = playlist takes the first two, which add up to 1003.
  3. Every typed array is iterable. Checking typeof on a Float32Array shows function: all 11 types inherit this iterator method.

Browser & Runtime Support

TypedArray.prototype[Symbol.iterator]() is part of ES2015 (ES6), the same edition that introduced symbols, iterators, and for...of.

✓ Baseline · ES2015

TypedArray.prototype[Symbol.iterator]()

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
[Symbol.iterator]() Excellent

Bottom line: Safe everywhere modern JavaScript runs. Internet Explorer has no Symbol at all, so neither this method nor for...of exists there.

Frequently Asked Questions

It is the built-in method that returns an iterator over the elements. JavaScript calls it automatically whenever you use a typed array in for...of, spread, Array.from(), or array destructuring.
Yes. ta[Symbol.iterator] === ta.values is true, so both return the same kind of iterator with the same elements in the same order.
Symbol.iterator is a symbol, not a normal property name, so ta.Symbol.iterator does not work. Square brackets accept any key, including a symbol.
for...of loops, the spread syntax [...ta], Array.from(ta), array destructuring such as const [a, b] = ta, and new Set(ta).
Yes. Every type inherits it from the hidden TypedArray parent class, since ES2015. On BigInt64Array and BigUint64Array the iterator gives BigInt values.

Back to the TypedArray Method Index

Browse all 34 TypedArray method guides, grouped by what they do.

TypedArray methods →

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