Example 1 — Quick demo
Core GeneratorFunction idea.
JavaScript
function* g() { yield 1; }
console.log(g.constructor.name);
console.log(g().next().value);How It Works
- function*. Creates a generator function.
- constructor.name. GeneratorFunction.
GeneratorFunction is the constructor of generator functions. Prefer function* syntax; the constructor is mainly for advanced metaprogramming.
| Topic | Summary |
|---|---|
basics | core GeneratorFunction usage. |
function* g() { yield 1; }
console.log(g.constructor.name);
console.log(g().next().value);Core GeneratorFunction idea.
function* g() { yield 1; }
console.log(g.constructor.name);
console.log(g().next().value);CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful