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

When yield* delegates to an inner iterator that lacks a throw method, and the consumer calls .throw() on the outer generator, what does the spec require to happen?

function makeIter() { return { [Symbol.iterator]() { return this; }, next() { return { value: 1, done: false }; }, return(v) { console.log('return called'); return { value: v, done: true }; } // note: no throw method }; } function* outer() { yield* makeIter(); } const it = outer(); it.next(); it.throw(new Error('x'));