const foo = function* () {
yield 'a';
yield 'b';
yield 'c';
};
let str = '';
for (const val of foo()) {
str = str + val;
}
console.log(str);
// Expected output: "abc"
This is a example of js generators function. But where are we going to use this function in daily software development.
Like Closure applications are private variables implementation, counter, rate limitter.