Favorites

JavaScript yield Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
yield
JavaScript Other OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

The yield operator pauses a generator function and hands a value back to the caller. yield* hands over every value of another iterable.

Description

The yield operator is used inside generator functions (function*). Each time it runs, the generator pauses and the value is returned from the caller's next() call as { value, done: false }. When next() is called again, the generator continues after the yield, and the argument passed to next() becomes the result of the yield expression.

yield* delegates to another iterable or generator, yielding each of its values in turn.

When a generator finishes with a return statement, its value appears as the final { value, done: true } result, but for...of and spread syntax ignore it. yield can only be used directly inside a generator function, not in a nested regular function or callback, which means you can't yield from inside a forEach().

Properties

Operator
yield
Category
Other
Precedence
2 (1 is lowest, 18 is highest)
Associativity
right-to-left

Syntax

yield
yield expression
yield* iterable

Example

function* letters() {
  yield 'a';
  yield* ['b', 'c'];
  const reply = yield 'd';
  console.log('got', reply);
}
const g = letters();
console.log(g.next().value, g.next().value, g.next().value, g.next().value);
g.next('hello');

Browser Support

The following information will show you the current browser support for the yield operator. Hover over a browser icon to see the version that first introduced support for this operator.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee