Explain the concept of Event Loop in JavaScript.
Instruction: Describe the event loop mechanism and its role in handling asynchronous operations.
Context: This question tests the candidate's understanding of the asynchronous nature of JavaScript and how the event loop facilitates non-blocking operations.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
In a browser, JavaScript execution on a given event loop runs a job to completion before that loop runs another job. The browser coordinates tasks such as event callbacks and timers with microtasks such as promise reactions. Asynchronous I/O can make progress outside the currently running JavaScript, but a long CPU-bound callback still blocks other work on that main thread...