InterviewSolution
Saved Bookmarks
| 1. |
What is an event-loop in Node JS? |
|
Answer» Whatever that is async is managed by event-loop using a queue and listener. We can GET the idea using the following diagram: Node.js Event LoopSo when an async function needs to be executed(or I/O) the main THREAD SENDS it to a different thread allowing v8 to keep executing the main code. Event loop involves different phases with specific tasks such as timers, pending callbacks, idle or prepare, poll, check, close callbacks with different FIFO QUEUES. ALSO in between iterations it checks for async I/O or timers and shuts down cleanly if there aren't any. |
|