Skip to content

Example using generators with for..of and spread #27

Description

@tomscallon

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions