function *testGen() {
console.log('print some');
yield 1;
yield 2;
yield 3;
}
const it = testGen();
it.next(); //1 { value: 1, done: false }
it.next(); //2 { value: 2, done: false }
it.next(); //3 { value: 3, done: false }
it.next(); //undefined { value: undefined, done: false }
网友评论