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월.
Generator 객체는 generator function 으로부터 반환되며, 반복 가능한 프로토콜과 반복자 프로토콜을 모두 준수합니다.
이 객체는 바로 인스턴스화할 될 수 없습니다. 대신 제너레이터 함수를 통해 Generator 인스턴스를 반환할 수 있습니다.
yield 표현식을 통해 yield된 값을 반환합니다.
Generator.prototype.return()주어진 값을 반환하고 제너레이터를 종료합니다.
Generator.prototype.throw()제너레이터에 오류를 발생시킵니다. (해당 제너레이터 내에서 오류가 발생한 경우가 아닌 한 제너레이터도 완료)
제너레이터 함수를 사용하면 값은 필요할 때까지 계산되지 않습니다. 따라서 제너레이터는 잠재적으로 무한한 데이터 구조를 정의할 수 있습니다.
| ECMAScript® 2027 Language Specification # sec-generator-objects |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2022년 12월 29일 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.