setTimeout在主thread执行完后执行
setTimeout(function() { alert('World'); }, 0); alert('Hello');
先hello ,后 world
This can be useful in cases where you want to set a block of code to run as soon as all of the main thread has finished running — put it on the async event loop, so it will run straight afterwards.
clearTimeout() and clearInterval() both use the same list of entries to clear from. Interestingly enough, this means that you can use either method to clear a setTimeout() or setInterval().
阅读量: 576
发布于:
修改于:
发布于:
修改于: