function* 表达式
function*关键字可以在表达式内部定义一个生成器函数。
function* foo() {
yield 'a';
yield 'b';
yield 'c';
}
let str = '';
for (const val of foo()) {
str = str + val;
}
console.log(str);
console.log(foo())
// expected output: "abc"
function* foo() {
yield 'a';
yield 'b';
yield 'c';
}
let str = '';
for (const val of foo()) {
str = str + val;
}
console.log(str);
console.log(foo())
// expected output: "abc"