May 31, 2020 in Node.Js
Q:

What is Event loop in Node.js work? And How does it work?

1 Answer

0 votes
May 31, 2020

The Event loop handles all async callbacks. Node.js (or JavaScript) is a single-threaded, event-driven language. This means that we can attach listeners to events, and when a said event fires, the listener executes the callback we provided.

Whenever we are call setTimeout, http.get and fs.readFile, Node.js runs this operations and further continue to run other code without waiting for the output. When the operation is finished, it receives the output and runs our callback function.

So all the callback functions are queued in an loop, and will run one-by-one when the response has been received.

Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

+1 vote
May 31, 2020 in Node.Js
...