Let us understand this with the help of an example.
In the above code snippet, the first line of the code
Hi will be logged first then the second line
Mayukh will be logged and then after its completion, the third line would be logged
How are you.
So as we can see the codes work in a sequence. Every line of code waits for its previous one to get executed first and then it gets executed.
So, what the code does is first it logs in
Hi then rather than executing the
setTimeout function it logs in
End and then it runs the
At first, as usual, the
- How to Run Synchronous Queries using sync-sql Module in Node.js ?
- Asynchronous Patterns in Node.js
- How to write asynchronous function for Node.js ?
- Asynchronous file transfer in AJAX
- Asynchronous Functions and the Node Event Loop
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.