Since both falls in the "Timers" phase of Event Loop in Javascript/Node.js -
let racer = function () {
setInterval(() => { console.log('Interval is here') }, 2000);
setTimeout(() => { console.log('Timeout is here') }, 2000);
}
Just looking for initial order of execution of above code snippet?
W3C specification does not seem to indicate any priority between the list of active timeouts
and the list of active intervals
.
Therefore the execution order of your racer
function depends on browser implementation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.