JavaScript is single-threaded, but it can still handle things like API calls, timers, and user actions without freezing the app.
The event loop is a system that decides:
It helps JavaScript handle asynchronous tasks smoothly.
Promise.thenasync/awaitsetTimeoutsetIntervalThe event loop runs like this:
👉 Just remember:
Sync → Microtasks → Macrotasks
console.log("A");setTimeout(() => { console.log("B");}, 0);Promise.resolve().then(() => { console.log("C");}).then(() => { console.log("D"); });queueMicrotask(() => { console.log("E");});(async function () {console.log("F");await null;console.log("G");})();console.log("H");
FHCEDGB