Mid
From PDF
Node.js
Node.js
How does Node.js handle asynchronous code internally?
Short answer: Explain the event loop phases. Node.js uses the event loop to handle async tasks without blocking. Main phases: Timers: Executes callbacks scheduled by setTimeout and setInterval. Pending callbacks: Executes I/O callbacks deferred to next iteration. Idle, prepare: Internal operations. Poll: Retrieves new I/O events; executes I/O callbacks. Check: Executes callbacks scheduled by setImmediate. Close callbacks: Handles…
Explain a bit more
closed connections. Tasks are processed in this order each loop iteration.
Real-world example (ShopNest)
ShopNest’s Node API handles many checkout requests concurrently because I/O (DB/HTTP) is non-blocking on the event loop.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png