MediumGenerators & Iterators💻 Output Question

yield* delegates to another iterable

💡

Hint

yield* delegates iteration to any iterable — another generator, array, string, etc.

What does this output?

function* inner() { yield 'a'; yield 'b'; }
function* outer() {
  yield 1;
  yield* inner();
  yield 2;
}
console.log([...outer()].join(','));

Correct Output

1,a,b,2

Why this output?

Explanation: yield* delegates to inner(). outer yields 1, then all of inner (a, b), then 2.

Key Insight: yield* delegates iteration to any iterable — another generator, array, string, etc.

More Generators & Iterators Output Questions

MediumGenerator pauses at yield, done true at endMediumreturn in generator — spread ignores return valueEasyGenerator as lazy rangeMediumCustom iterable with Symbol.iterator

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz