Event Loop Nature
Question
What does the JavaScript event loop do?
Hint
The event loop handles the call stack and callback queue.
Explanation
The event loop continuously checks if the call stack is empty. When it is, it takes the first callback from the macrotask queue (or microtask queue, which has priority) and pushes it onto the stack. This is how JavaScript achieves non-blocking I/O despite being single-threaded. setTimeout, fetch, and Promises all use this mechanism.
Related Resources
Related Lessons
- Async JavaScript
Learn async JS.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.