![]() It will encounter the setTimeout function, which is a Macro task, and it will be executed in the next event Loop.Īnd now, you might be wondering what a Macro task is. Now, the event loop will move to the second line and push it into the call stack. We will get “First!” in the console and it will be moved out of the call stack. console.log('First!') Īs usual, our code will move into the call stack and the event loop will loop through line by line. To understand things better, let’s take a look at another example. Our console will print the following result: The next line will be stored in the call stack and will be flagged for execution. When the First() finishes its execution, it will be popped out of the call stack and the event loop will go down to the next line. In the above example, we can see that we are logging two values in the console. It has a call stack and all the code is executed inside this call stack. JavaScript is a single-threaded programming language which means that only one task can run at a time. In this tutorial, we are going to learn how to use Async/Await in JavaScript.īut before we get there, we should understand a few topics like:Įvent loops are one of the most important aspects of JavaScript.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |