generator function in javascript yield.all code example
Example: javascript yield
function* foo(index) {
while (index < 2) {
yield index;
index++;
}
}
const iterator = foo(0);
console.log(iterator.next().value);
// expected output: 0
console.log(iterator.next().value);
// expected output: 1