generator use
Parameter passing when the first call to next makes no sense to print out any results
function * Read () { the let A = the yield. 1 ; the console.log (A); the let B = 2 the yield ; the console.log (B); the let C = the yield. 3 ; the console.log (C); } the let IT = Read ( 'A' ); it.next (); // parameter passing when the first call to next makes no sense
Output:
[Done] exited with code=0 in 0.405 seconds
Next will be printed in the order that calls next
function * Read () { the let A = the yield. 1 ; the console.log (A); the let B = 2 the yield ; the console.log (B); the let C = the yield. 3 ; the console.log (C); } the let IT = Read ( 'a' ); it.next (); // pass the first call to next parameter does not make sense it.next ( '100'); // prints the value of a time when the execution is a value call the next method passed in is // print the value of a it.next ( '200 is' ); it.next ( '300');
Output:
[Running] node "d: \ cloud code \ zhufengjiagoukecheng \ Generator \ tempCodeRunnerFile.js"
100
200
300