This doesn’t seem right, but this is how Firefox appears to be acting.
setTimeout(print(),5000);
function print(){
console.log(1);
}
Before the 5 seconds are up, after a link is clicked and before the next page begins to render, 1 is printed to the console. Any ideas? Thanks!
Edit: retitled, to make it obvious that there is a bug in the example code, not in firefox behavior.
No, the problem is that you are executing the print function immediately. Remove the brackets so you pass the function object rather than execute it.