| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/Symbol.iterator | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2016 9.
const array1 = ["a", "b", "c"];
const iterator1 = array1[Symbol.iterator]();
for (const value of iterator1) {
console.log(value);
}
// Expected output: "a"
// Expected output: "b"
// Expected output: "c"
array[Symbol.iterator]()
.
. [Symbol.iterator] , for...of .
<ul id="letterResult"></ul>
const arr = ["a", "b", "c"];
const letterResult = document.getElementById("letterResult");
for (const letter of arr) {
const li = document.createElement("li");
li.textContent = letter;
letterResult.appendChild(li);
}
next .
const arr = ["a", "b", "c", "d", "e"];
const arrIter = arr[Symbol.iterator]();
console.log(arrIter.next().value); // a
console.log(arrIter.next().value); // b
console.log(arrIter.next().value); // c
console.log(arrIter.next().value); // d
console.log(arrIter.next().value); // e
, . Array.prototype.values() .
function logIterable(it) {
if (typeof it[Symbol.iterator] !== "function") {
console.log(it, "is not iterable.");
return;
}
for (const letter of it) {
console.log(letter);
}
}
// Array
logIterable(["a", "b", "c"]);
// a
// b
// c
// String
logIterable("abc");
// a
// b
// c
// Number
logIterable(123);
// 123 .
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-array.prototype-%symbol.iterator% |
core-js Array.prototype[Symbol.iterator] ArrayArray.prototype.keys()Array.prototype.entries()Array.prototype.values()TypedArray.prototype[Symbol.iterator]()String.prototype[Symbol.iterator]()Symbol.iteratorThis page was last modified on 2025 10 10 by MDN contributors.
Arrayat()concat()copyWithin()entries()every()fill()filter()find()findIndex()findLast()findLastIndex()flat()flatMap()forEach()includes()indexOf()join()keys()lastIndexOf()map()pop()push()reduce()reduceRight()reverse()shift()slice()some()sort()splice()toLocaleString()toReversed()toSorted()toSpliced()toString()unshift()values()with()[Symbol.iterator]()Object/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |