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

What does this generator print and return, given that the finally block contains its own yield? This probes how a finally that yields interacts with a return() completion.

function* g() { try { yield 1; } finally { yield 'fin'; } } const it = g(); it.next(); console.log(it.return(42)); // ? console.log(it.next()); // ?