const createCycle = (...callbacks) => {
const generator = (function* () {
let index = 0;
while (true) {
yield callbacks[index++];
index %= callbacks.length;
}
})();
return generator;
};
const cycledCallbacks = createCycle(
(name) => console.log(`Hello, ${name}`),
(name) => console.log(`Bye, ${name}`)
);
const button = document.querySelector('button');
button.addEventListener('click', event => {
event.preventDefault();
const { value: callback } = cycledCallbacks.next();
callback('John');
});
<input type="submit" class="btn btn-sm btn-info" name="btn" onclick=" alf(); return num(this);"/>
function alf(){
if(func1==true){
//что то есть
}
func2=true;
}
function num(){
if(func2==true){
//что то есть
}
func1=false;
}