A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-72.js
1letorder=[];
2Promise.resolve().then(()=>order.push('p'));
3queueMicrotask(()=>order.push('q'));
4Promise.resolve().then(()=>{
5console.log(order.join(','));
6});
Async
Answer & explanation
Console output
p,q
Why
Promise .then callbacks and queueMicrotask callbacks share the same microtask queue and run in the order they were scheduled. Here "p" is queued, then "q", then the logging callback. The FIFO queue runs them in that order, so by the time the log runs, order already contains ["p", "q"].