Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaScriptgenerator return throw protocolSingle-choice MCQ

When a generator delegates with yield* to a custom iterator, and the outer iterator's return() is called, what happens to the delegate?

function inner() { return { [Symbol.iterator]() { return this; }, next() { return { value: 'in', done: false }; }, return(v) { console.log('inner return', v); return { value: v, done: true }; } }; } function* outer() { yield* inner(); } const it = outer(); it.next(); // { value: 'in', done: false } it.return(42);