Have you wondered how Javascript works behind the scene?Curious?Then you will enjoy this reading.Especially,I have made this post together with other posts preparing those that follow my DATA STRUCTURES AND ALGORITHMS SERIES.Its tough stuff,but eventually it will become part of you if you read and practice often.

What is JavaScript event loop?

Let’s get a piece of code ,run it in our browser,observe what happens in the console.Then we get on with our discussion.

JavaScript

const first = () => console.log("First function");
const second = () => setTimeout(() => console.log("Second function"), 1000);
const third = () => console.log("Third function");
​
first();
second();
third();
​

Yes,if you have no idea how to set it up,check the screen shot of how I set up mine below.

Then run the code in your favourite browser.I run mine in chrome.Yap,it will be a blanck screen because we are using the console.Open the console……right click in the open space and then click console in the context menu that pops.My result show as indicated in the screen shot below.

It shows that during execution, the JavaScript engine skipped the second function, went on to execute the third, then came back to run the second function.

#javascript #web-development #developer

JavaScript Event Loop
2.70 GEEK