Do you know what will be the output of this code?
JavaScript
setTimeout(() => console.log("timeout"));
queueMicrotask(() => console.log("microtask"));
console.log("sync");
Show answer and explanation
The answer is sync microtask timeout.
queueMicrotask uses the same queue as promise callbacks. Microtasks run as soon as the current synchronous code finishes, before the event loop moves on to timers.