Generator functions in JS
function* getNames() {
yield "John";
yield "Jim"
}
const genName = getNames();console.log("genName",genName.next().value);console.log("genName 2nd Time", genName.next().value);function* autoIncrementer() {
let counter = 0;
while(true) {
yield counter++;
}
}
const counter = autoIncrementer();
console.log("autoIncrementer", counter.next());

Saurabh Mhatre

Blogger,web and hybrid applications developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store