Skip to main content
PProfileMatch
← Path

JavaScript Fundamentals · JavaScript Promises, async/await and fetch Explained

0 XP
  1. 1 current stop: learning
  2. 2 upcoming
  3. 3 upcoming
  4. 4 upcoming
  5. 5 upcoming

Finish after stop 5

Stop 1 of 5 · Start line: one lane, a waiting room

Trick to keep in mind+3 XP

Code now, promises next, timers later

JavaScript finishes the synchronous code it is running before it looks at any queue. Then it drains the microtask queue, where promise callbacks wait, and only afterwards runs the next timer or event callback. A setTimeout of 0 ms still goes to the back of the line behind promise callbacks.

Read it once, then a question tests whether the trick stuck.