OutputNot attempted
for...of ignores the return value
function* g() { yield 1; yield* [2, 3]; return 4;}console.log([...g()]);for (const v of g()) console.log(v);Spaces and quote style don’t matter · write a thrown error as TypeError
Ctrl Enter
Show answer & explanation
The expected output comes from actually running the snippet; opening this shows it next to the explanation.
Spread and for...of stop as soon as done is true, and the value that comes WITH done: true (the return value) is dropped. yield* delegates to another iterable, one value at a time.