32
loading...
This website collects cookies to deliver better user experience
() => {
console.log(6);
queueMicrotask(() => ..);
} is executed logging 6 on console and adding another callback to job queue.
() => console.log(7) is pushed onto stack and executed.
Now since the job queue is empty, the task queue is checked again to see if any task is pending.
So () => { console.log('interval') } is pushed onto stack and executed.
queueMicrotask(() => ..) is executed adding callback function to job queue.
console.log(4); is pushed onto stack and executed.
() => {
console.log(2);
setTimeout( () => {
console.log(3);
clearInterval(interval);
}, 0);
} is executed logging 2 on console and adding another task to task queue.
() => { console.log('interval') } is pushed onto stack and executed.
() => {
console.log(3);
clearInterval(timer);
} is executed logging 3 on console and clearing the interval.