JavaScript

Explain the event loop

Hard
5
Added
JavaScript runtime uses a message queue and event loop to handle async operations in a single thread.

Solution Code

JavaScript
setTimeout(() => console.log('hi'), 0);
Explanation
The event loop continuously checks the call stack and processes callback queue when empty.

Guided Hints

How does JavaScript handle concurrency?
Difference between macro and micro tasks