function* fibonacciGenerator() {
let a = 0,
b = 1;
while (true) {
yield a;
[a, b] = [b, a + b];
}
}
const genFib = fibonacciGenerator();
console.log(genFib.next().value);
console.log(genFib.next().value);
console.log(genFib.next().value);
console.log(genFib.next().value);
console.log(genFib.next().value);
ZnVuY3Rpb24qIGZpYm9uYWNjaUdlbmVyYXRvcigpIHsKICBsZXQgYSA9IDAsCiAgICBiID0gMTsKICB3aGlsZSAodHJ1ZSkgewogICAgeWllbGQgYTsKICAgIFthLCBiXSA9IFtiLCBhICsgYl07CiAgfQp9Cgpjb25zdCBnZW5GaWIgPSBmaWJvbmFjY2lHZW5lcmF0b3IoKTsKCmNvbnNvbGUubG9nKGdlbkZpYi5uZXh0KCkudmFsdWUpOwpjb25zb2xlLmxvZyhnZW5GaWIubmV4dCgpLnZhbHVlKTsKY29uc29sZS5sb2coZ2VuRmliLm5leHQoKS52YWx1ZSk7CmNvbnNvbGUubG9nKGdlbkZpYi5uZXh0KCkudmFsdWUpOwpjb25zb2xlLmxvZyhnZW5GaWIubmV4dCgpLnZhbHVlKTsK