JavaScript Array [Symbol.iterator]() Method

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

Definition

array[Symbol.iterator]() is the special method that makes an array iterable. JavaScript calls it for for...of, spread [...array], destructuring, and Array.from(array).

For arrays it is the same function as values(). You rarely call it by hand.

Syntax

Usually used through for...of or spread. You can also call it with square brackets.

JavaScript
const nums = [10, 20, 30];

for (const n of nums) {
  console.log(n);
}

const iterator = nums[Symbol.iterator]();
console.log(iterator.next().value);
CallWhat it does
for (const x of array)Loop values; the loop calls [Symbol.iterator]().
[...array]Spread values into a new array.
array[Symbol.iterator]()Get the iterator object yourself.

Standard ES2015 method on Array.prototype. Same function as values().

Parameters

ParameterDescription
(none)Call as array[Symbol.iterator]() with no arguments.

Return Value

Return ValueDescription
Array IteratorIterator of element values in index order. Each next() returns { value, done }.

JavaScript Examples

Example 1 — for...of and Spread

Everyday features that call the iterator for you.

JavaScript
const colors = ["red", "green", "blue"];

for (const color of colors) {
  console.log("Loop: " + color);
}

console.log("Spread: " + [...colors].join(", "));
Try It Yourself

How It Works

  1. for...of. The loop asks the array for its iterator and reads values in order.
  2. Spread. [...colors] builds a shallow copy via the same iterator.
  3. Same as values(). colors[Symbol.iterator] === colors.values is true.

Example 2 — Call It Yourself

Step through the iterator with next().

JavaScript
const list = ["a", "b"];
const it = list[Symbol.iterator]();

console.log(it.next());
console.log(it.next());
console.log(it.next());
console.log(list[Symbol.iterator] === list.values);
Try It Yourself

How It Works

  1. Get an iterator. Calling the method returns an object with next().
  2. Step until done. After the last value, done becomes true.
  3. Alias. The method is the same function as values().

Example 3 — Is It Iterable?

Test whether a value has Symbol.iterator.

JavaScript
function isIterable(x) {
  return x != null && typeof x[Symbol.iterator] === "function";
}

console.log(isIterable([1, 2]));
console.log(isIterable("hi"));
console.log(isIterable({ a: 1 }));
Try It Yourself

How It Works

  1. Arrays and strings are iterable.
  2. Plain objects are not, unless you add a custom iterator.
  3. Use the test before spreading unknown values.

Browser & Runtime Support

Array.prototype[Symbol.iterator] is part of ES2015 with for...of and iterators.

✓ ES2015 ยท Widely supported

array[Symbol.iterator]()

Supported in modern browsers and Node.js 4+. Internet Explorer needs a polyfill.

ES2015 Standard since
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
array[Symbol.iterator]() Excellent

Bottom line: Safe in every current browser and Node.js.

Frequently Asked Questions

It is the method that makes arrays iterable so for...of, spread, and Array.from can read elements one by one.
Yes. Array.prototype[Symbol.iterator] is the same function as Array.prototype.values.
Use square brackets: array[Symbol.iterator](). Most of the time for...of is easier.
No. It returns an iterator over the current elements. Spread [...array] builds a new array from that iterator.
Read the values() tutorial for the same iterator with a clearer name, or entries() for index/value pairs.

Next: Array overview

Return to the Array hub for every method.

Array hub →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

9 people found this page helpful