JavaScript runs on a single thread. Long synchronous work blocks everything, including rendering. Asynchronous callbacks are queued: promise callbacks go on the microtask queue, which drains before the next macrotask such as a `setTimeout`.
setTimeout(() => console.log("timeout"));
Promise.resolve().then(() => console.log("micro"));
console.log("sync");
// sync, micro, timeoutThat ordering explains most "why did this log first?" confusion.