I knew, how i got { value:6, done:false }
at first time.But,next values how can it be { value:8, done:false }
and { value:42, done:true }
//-----------code-----------//
function* foo(x) {
var y = 2 * (yield (x + 1));
var z = yield (y / 3);
return ('OP'+x + y + z);
}
var it = foo( 5 );
// note: not sending anything into `next()` here
console.log( it.next() ); // { value:6, done:false }
console.log( it.next( 12 ) ); // { value:8, done:false }
console.log( it.next( 13 ) ); // { value:42, done:true }
Aucun commentaire:
Enregistrer un commentaire