Example using generators with for..of and spread
tomscallon opened this issue · 0 comments
tomscallon commented
E.g. with
function* numbers(x) {
yield 1;
yield 2;
yield 3;
yield x;
}
For..of:
for (const x of numbers(99)) {
console.log(x);
}
// => 1
// => 2
// => 3
// => 99
Spread:
const arr = [...numbers(99)];
console.log(are);
// => [1, 2, 3, 99]