Event Loop #Node.js Quick Notes.

Ajay Baraiya - Sep 5 '22 - - Dev Community

Remember below things first before starting understanding Event Loops.

  1. The Node.Js JavaScript Code Runs On A Single Thread.
  2. Node.Js Call Stack Is A LIFO (Last In, First Out) Stack.

When browser loop through events, it gives priority to callstack and everything else like click events, setTimeout timers, load events put into Message queue.

Once callstack finished than it goes to Message queue and take execute it from there.

To make it in sequence we can you Promises and Async/Await.

. . . . . . . . . . . . . . . . . . .