Skip to content

Instantly share code, notes, and snippets.

@Rihovardini
Last active July 24, 2018 06:39
Show Gist options
  • Save Rihovardini/d1f484fc81ca8fc27e1fc9206ec33e2c to your computer and use it in GitHub Desktop.
Save Rihovardini/d1f484fc81ca8fc27e1fc9206ec33e2c to your computer and use it in GitHub Desktop.
Event loop

Event loop

  1. The command console.log(1) gets into call stack and executing there.
  2. Next, the command setTimeout(func,0) tells to call stack to run the callback when all current stream is finished.SetTimeout makes it async and gets out function from the curren stream.Callback's gonna go to web Api,callback queue and call stack.
  3. Finally,console.log(3) is gonna run before setTimeout callback, cause this function is in current stream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment