Thursday, September 22, 2022
HomeWordPress DevelopmentPerceive synchronous Vs asynchronous code in Js

Perceive synchronous Vs asynchronous code in Js


Synchronous code runs step-by-step the place every step has to attend for earlier one to be executed.

Instance:

console.log("Hey Mates");
console.log("Hey");
console.log("Good to satisfy you");
Enter fullscreen mode

Exit fullscreen mode

Right here every line will execute then subsequent till all end.

Image description

However for asynchronous code it does not respect order stuff ,it get executed out of sequence.
Instance:

console.log("Hey");
setTimeout(()=>console.log("Look forward to 3 Second"),3000);
console.log("See you once more");
Enter fullscreen mode

Exit fullscreen mode

First line will execute and final whereas for second one it has to attend for 3seconds to it’s going to execute final.

Image description
I am grateful that you just took the time to learn my writing, and I hope it’s going to aid you develop. Let’s collaborate to brighten the longer term. All of my major profiles can be found on My Github

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments