1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
'use strict'; const p = console.log; const generatorFunction = function* () { yield 1; yield 2; yield 3; }; const generatorArrowFunction = () => { const generatorInnerFunction = function* () { yield 1; yield 2; yield 3; }; return generatorInnerFunction(); }; const generator3main = () => { const g1 = generatorFunction(); const g2 = generatorArrowFunction(); p(g1.next().value); p(g1.next().value); p(g1.next().value); p(g1.next().value); p(g2.next().value); p(g2.next().value); p(g2.next().value); p(g2.next().value); }; // module.exports = generator3main; generator3main(); |
1 2 3 4 5 6 7 8 |
1 2 3 undefined 1 2 3 undefined |