Javascript event loop | Every Javascript developer must know !




#events #eventloop #javascript
This video covers the concept of event loop in Javascript. After watching this video, you will have a greater understanding of how Javascript is capable of handling asynchronous events even though the runtime is single threaded.
This video covers callback functions. To learn more about promises, check out our video dedicated to promises here:


Original source


48 responses to “Javascript event loop | Every Javascript developer must know !”

  1. Answer will be alpha , gamma , beta . Explanation : Even there is no delay in setTimeout i.e 0 seconds but since setTimeout will be delegated to browser's web api , which will store the execution of function inside setTimeout in Event Queue. Now the function inside this event queue will be only executed once the entire call stack is empty . Now already func is in call stack and it will be only removed from the call stack when entire function is executed that console.log(''gamma") is printed . Now after this only call stack will be empty and function stored in event queue (i.e console.log('beta")) will get a chance to execute. Hence the answer is alpha , gamma , beta.

Leave a Reply