1.

What do you mean by Event Loop and how does it work in Node.js?

Answer»

A mechanism which is designed to handle async callbacks is known as Event loop. Node.js is a single threaded and event driven programming language. We can attach any listener on the request node and whenever it is triggered with a known request then listener will accept and process it based on the PREDEFINED callback functions which we have setup in our APPLICATION.    

At whatever point we are callingsetTimeout, http.get and fs.readFile, Node.js runs these tasks and further keeps on running other PROGRAMS without waiting for the output. At the point when the activity is done, it gets the output and runs our callback function.  

So all the callback functions are LINED in a circle, and will RUN individually whenever we receive the response. 



Discussion

No Comment Found