generator js code example
Example 1: generators in javascript
function* g(){
console.log("First");
yield 1;
console.log("second");
yield 2;
console.log("third");
}
let generator=g();
generator.next();
generator.next();
Example 2: js generator
function* fibonacci() {
var a = yield 1;
yield a * 2;
}
var it = fibonacci();
console.log(it);
console.log(it.next());
console.log(it.send(10));
console.log(it.close());
console.log(it.next());
Example 3: function generator js
function* name([param[, param[, ... param]]]) {
statements
}