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. It’s been available across browsers since 2016년 9월.
Array 인스턴스의 [Symbol.iterator]() 메서드는 순회 가능 프로토콜을 구현하며, 배열을 전개 구문이나 for...of 루프와 같이 순회 가능을 기대하는 대부분의 구문에서 사용할 수 있도록 합니다. 이 메서드는 배열의 각 인덱스 값을 산출하는 배열 순회자 객체를 반환합니다.
이 속성의 초기 값은 Array.prototype.values 속성의 초기 값과 동일한 함수 객체입니다.
없음.
Array.prototype.values()와 동일한 반환 값입니다. 이는 배열의 각 인덱스의 값을 산출하는 새로운 순회 가능 순회자 객체입니다.
이 메서드를 직접 호출할 필요는 거의 없습니다. [Symbol.iterator] 메서드가 있으면 배열을 순회 가능으로 만들 수 있으며, for...of 루프와 같은 순회 구문은 이 메서드를 자동으로 호출하여 반복할 순회자를 얻습니다.
반환된 순회자 객체의 next 메서드를 수동으로 호출하여 순회 과정을 최대한 제어할 수 있습니다.
문자열과 배열은 모두 순회 가능 프로토콜을 구현하기 때문에, 범용 함수는 두 입력을 동일한 방식으로 처리하도록 설계할 수 있습니다. 이는 입력이 배열이거나 적어도 해당 메서드가 있는 객체여야 하는 Array.prototype.values()를 직접 호출하는 것보다 낫습니다.
| ECMAScript® 2027 Language Specification # sec-array.prototype-%symbol.iterator% |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 10월 10일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.