for(let i=0;i<5;iPP){
setTimeout(() => {
alert(i);
// console.log(i);
}, 0);
}
code, such as the above, has been tried in browsers such as chrome,safari, which will lead to confusion in the execution order of console.log code. A lot of explanations have been checked on the Internet, but the disorder can not be changed after testing. But there is nothing wrong with the same code in Firefox.
there are a few questions now:
- does alert blocking threads cause functions in the event queue to be out of order?
- how does the browser alert work?