JSFiddle - React, Tailwind, and code Playground
JavaScript
//Normal functions cannot be stopped
function normalFunction() {
console.log("cannot");
console.log("be");
console.log("stopped");
}
normalFunction()// cannot be stopped
//Generator function
function* generatorFunction() {
yield console.log("can");
yield console.log("be");
yield console.log("stopped");
}
const generator = generatorFunction();
generator.next().value; // can
generator.next().value; // be
generator.next().value; // stopped