Skip to content

Instantly share code, notes, and snippets.

@acidDrain
Created May 19, 2023 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acidDrain/e0058d884a2f0e43c21bf8fbf8b34048 to your computer and use it in GitHub Desktop.
Save acidDrain/e0058d884a2f0e43c21bf8fbf8b34048 to your computer and use it in GitHub Desktop.
Demonstrate the JavaScript event-loop
console.log("Before setTimeout\n");
setTimeout((): void => {
// prints out "2", meaning that the callback is not called immediately after 500 milliseconds.
console.log("Inside 'setTimeout' callback\n");
}, 1000);
console.log("After 'setTimeout'\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment