Concept Flow - Event loop overview
Start: JS code runs
Call stack executes sync code
Async task encountered?
Send async task to Web APIs
Async task completes
Callback added to task queue
Event loop checks call stack
If call stack empty, move callback to call stack
Callback executes
Repeat until all tasks done
JavaScript runs code on a call stack, sends async tasks to Web APIs, and uses the event loop to move callbacks back to the stack when ready.