remember watching Funfunfunction video on it but I didn't understood anything about them..
The type signature was something like,
function * name() {}
this was 2-3 years ago so I must be forgetting a lot of details..
That's a generator function
function* name() { yield 1; yield 2; yield 3; return 4; } const gen = name(); gen.next(); // { value: 1, done: false } gen.next(); // { value: 2, done: false } gen.next(); // { value: 3, done: false } gen.next(); // { value: 4, done: true } for (const x of name()) { console.log(x); // logs: 1, 2, 3 }
Обсуждают сегодня