What is logged?
function* g() {
yield 1;
yield 2;
return 3;
}
const it = g();
const a = [...it];
const b = it.next();
console.log(a.join(','), b.value, b.done);
- 1,2,3 3 true
- 1,2 undefined true
- 1,2 3 false
- 1,2 undefined false
0
voters
What is logged?
function* g() {
yield 1;
yield 2;
return 3;
}
const it = g();
const a = [...it];
const b = it.next();
console.log(a.join(','), b.value, b.done);
JS Quiz answer: Option 2 (B).
Correct choice: 1,2 undefined true
Why:
Spread consumes yielded values only and exhausts the iterator; next then returns done true with undefined value.
Go deeper:
Making Counting Sort Work With Negative Values
First-answer leaderboard
:: Copyright KIRUPA 2026 //--
``` ```