Junior — Senior
Determining the output sequence in the console (Example №99)
livecode
Task condition
You need to predict which values will appear in the console after executing the given code, and explain why they are output in that particular order.
console.log(1);
setTimeout(() => {
console.log(2);
}, 0);
Promise.resolve().then(() => {
console.log(3);
}).then(() => {
console.log(4);
});
queueMicrotask(() => {
console.log(5);
});
setTimeout(() => {
console.log(6);
}, 0);
console.log(7);