let hw = helloWorld() let a = hw.next() console.log(a) // {value: "hello", done: false} let b = hw.next() console.log(b) // {value: "world", done: false} let c = hw.next() console.log(c) // {value: "ending", done: true}
next 传参
1 2 3 4 5 6 7 8 9 10 11 12
function* gen() { let a = yield123 + 456 yield a * 2 return a } let g = gen() let aa = g.next() console.log(aa) // {value: 579, done: false} let bb = g.next(1) console.log(bb) // {value: 2, done: false} let cc = g.next() console.log(cc) // {value: 1, done: true}