JavaScript Iterator [Symbol.iterator]() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Instance method

Definition

iterator[Symbol.iterator]() is the method that makes an iterator iterable. On Iterator.prototype it simply returns the same iterator (this), so features that ask for an iterator can reuse the object you already have.

That is why you can write for (const value of someIterator), spread with [...someIterator], or pass an iterator to Array.from(). JavaScript calls [Symbol.iterator]() for you; you rarely need to call it by hand.

Remember
iterator[Symbol.iterator]()

returns the same iterator (this)
so iterators are also iterable

used by: for...of, [...it], Array.from(it)

call yourself only when learning
day to day: just use for...of

Syntax

You normally use it through for...of or spread. You can also call it with square brackets to see that it returns itself.

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

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

for (const n of it) {
  console.log(n);
}
CallWhat it does
for (const value of iterator)Loop over values. The loop calls [Symbol.iterator]() for you.
[...iterator]Spread remaining values into a new array.
Array.from(iterator)Build an array from the remaining values.
iterator[Symbol.iterator]()Call it yourself; it returns the same iterator.

A standard JavaScript method (ES2015) on Iterator.prototype, stored under the special symbol key Symbol.iterator. No import required. Siblings: Iterator.concat(), Iterator.from(), Iterator.zip(), Iterator.zipKeyed(), chunks(), drop(), every(), filter(), find(), flatMap(), forEach(), includes(), join(), map(), reduce(), some(), take(), toArray(), windows(), [Symbol.dispose]().

Library declarations
JavaScript
// ECMAScript 2015 (ES6)
Iterator.prototype[Symbol.iterator]()

// returns: the same iterator (this)

Parameters

ParameterDescription
(none)This method takes no parameters. Call it as iterator[Symbol.iterator]().

Return Value

Return ValueDescription
The same iteratorIt returns this. That single rule is what makes iterator objects usable anywhere an iterable is expected.

JavaScript Examples

Example 1 — Use for...of on an Iterator

Array iterators are iterable because [Symbol.iterator]() returns themselves.

JavaScript
const it = ["a", "b", "c"].values();

for (const letter of it) {
  console.log("Letter: " + letter);
}
Try It Yourself

How It Works

  1. Get an iterator. .values() returns an iterator of the three letters.
  2. for...of asks for an iterable. It calls it[Symbol.iterator](), which returns it itself.
  3. Values print in order. Each loop step is one next() until the iterator is done.

Example 2 — See That It Returns Itself

Call the method by hand and compare the result with the original iterator.

JavaScript
const it = [1, 2].values();

console.log("Type: " + typeof it[Symbol.iterator]);
console.log("Same object: " + (it[Symbol.iterator]() === it));

const step1 = it.next();
const step2 = it.next();
const step3 = it.next();

console.log("Step 1: " + step1.value + " " + step1.done);
console.log("Step 2: " + step2.value + " " + step2.done);
console.log("Step 3: " + step3.value + " " + step3.done);
Try It Yourself

How It Works

  1. It is a function. typeof it[Symbol.iterator] is "function".
  2. Same reference. Calling it returns the very same iterator object.
  3. Manual steps. Two values come out, then done becomes true.

Example 3 — Spread and Array.from on an Iterator

Both features need an iterable. Because the iterator returns itself, they work directly.

JavaScript
const doubled = [1, 2, 3].values().map((n) => n * 2);

const fromSpread = [...doubled];
console.log("Spread: " + fromSpread.join(", "));

const again = [4, 5].values().map((n) => n * 2);
const fromArray = Array.from(again);
console.log("Array.from: " + fromArray.join(", "));
Try It Yourself

How It Works

  1. Helper is still an iterator. map() returns another iterator that is iterable.
  2. Spread works. [...doubled] asks for [Symbol.iterator]() and reads every value.
  3. Array.from works too. A fresh mapped iterator becomes [8, 10].

Browser & Runtime Support

Iterator.prototype[Symbol.iterator]() has been part of iterators since ES2015. Every current browser and Node.js has it.

✓ ES2015 · Widely supported

iterator[Symbol.iterator]()

Supported in Chrome 38+, Edge 12+, Firefox 36+, Safari 9+, Opera 25+ and Node.js 4+. Internet Explorer never got it.

ES2015 Standard since
Google Chrome 38+ · Desktop & Mobile
Full support
Microsoft Edge 12+ · Chromium based
Full support
Mozilla Firefox 36+ · Desktop & Mobile
Full support
Apple Safari 9+ · macOS & iOS
Full support
Opera 25+ · Chromium based
Full support
Samsung Internet 3+ · Android
Supported
Android WebView 38+ · Chromium based
Supported
Node.js 4+ · Server runtime
Supported
Deno Recent versions · JavaScript runtime
Supported
Bun Recent versions · JavaScript runtime
Supported
Internet Explorer No native support
Not supported
iterator[Symbol.iterator]() Excellent

Bottom line: Safe to use everywhere modern JavaScript runs. It is what makes for...of, spread and destructuring work on iterators.

Frequently Asked Questions

It returns the same iterator object. That makes iterators iterable, so for...of, spread, and Array.from can read their values.
Many language features ask for an iterable first, then call next() on the iterator they get back. Returning this lets an existing iterator play both roles.
Use square brackets with the symbol: const same = iterator[Symbol.iterator](). Most of the time for...of is clearer.
Same idea, different return value. A Set creates a fresh values iterator. An Iterator returns itself so you keep walking the same position.
Yes. Helpers are iterators, and they inherit [Symbol.iterator](), so for...of and spread work on them.

Next: Method Index

See every JavaScript Iterator method in one place, grouped by what it does.

Iterator Methods index →

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.

12 people found this page helpful