Generators (Yield)
The generator will pause itself and the iterator will resume it. It can start and stop infinite number of time.
function* gen(){
console.log("Hello");
//The function will resume itself waiting for the next iterator
yield null;
console.log("World");
}
var it=gen();
it.next(); //prints "Hello"
it.next(); //print "World"
The generator will pause itself and the iterator will resume it. It can start and stop infinite number of time.
function* gen(){
console.log("Hello");
//The function will resume itself waiting for the next iterator
yield null;
console.log("World");
}
var it=gen();
it.next(); //prints "Hello"
it.next(); //print "World"
No comments:
Post a Comment