Hint
return in a generator terminates it. Spread/for...of ignores the return value — only yields are collected.
function* gen() {
yield 1;
return 99;
yield 2;
}
const values = [...gen()];
console.log(values.length);
console.log(values.join(','));1 1
Explanation: Spread stops at done:true. return gives {value:99, done:true} — spread ignores it. yield 2 unreachable.
Key Insight: return in a generator terminates it. Spread/for...of ignores the return value — only yields are collected.