Home/Tutorials/JavaScript/Callbacks and the Event Loop

0 of 2 saved

JavaScript5 min read

Callbacks and the Event Loop

Read this chapter, then pass a short check to open the next one.

Why JS feels async.

Callbacks and the Event Loop

JS runs on one main thread. Async work is scheduled; callbacks run later when the event loop allows.

  • setTimeout queues a macrotask.
  • Promises queue microtasks.
  • Never block the thread with busy waits.
console.log("A");
setTimeout(() => console.log("C"), 0);
console.log("B");

Write may be quiz-only here โ€” focus on the order A, B, then C.