I'm running through JavaScript: the Definitive Guide
It offers up the following code to explain setTimeout() and setInterval(), and my issue is that it runs in Safari without issue
but in Mozilla it doesn't seem to trigger at all, anyone have any
thoughts?
The issue is in the following function:
function invoke(f,start,interval,end){
if(!start) start=0; //default to 0ms (start right away)
if (arguments.length <= 2)
setTimeout(f,start);
It functions if I don't set the inverval and end, but if I do something goes janky
else{
setTimeout(repeat,start);
function repeat(){
var h = setInterval(f,interval);
//if(end)setTimeout(function(){clearInterval(h)},end);
}
}
}
This is just the dummy function that runs on setTimeout() and setInterval()
function f(){
if(true)
alert("yo");
}
<button onclick="invoke('f,200,1000,5000')">yo</button>
Hopfully somone has some insight into this one, thanks.
jankyisn't a very descriptive term and last I looked wasn't in my programming dictionary. Did you try it without a blocking alert? Try using just a console.log() instead.