| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/yield | [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.
[rv] = yield [expression];
expressionrv , optional value next() .
yield yield [expression] caller . return .
yield value done IteratorResult . value yield (expression) , done (Boolean) .
yield , next() . next() :
yield . next() , yield .throw . , .IteratorResult caller undefined done true .return . , IteratorResult caller return done true .optional value next() , optional value yield .
generator , yield, Generator.prototype.next() .
.
function* foo() {
var index = 0;
while (index <= 2)
// when index reaches 3,
// yield's done will be true
// and its value will be undefined;
yield index++;
}
, iterator .
var iterator = foo();
console.log(iterator.next()); // { value: 0, done: false }
console.log(iterator.next()); // { value: 1, done: false }
console.log(iterator.next()); // { value: 2, done: false }
console.log(iterator.next()); // { value: undefined, done: true }
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # prod-YieldExpression |
This page was last modified on 2024 12 17 by MDN contributors.
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 |