Generator
2017-08-28 本文已影响0人
O8
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 }