Skip to content

Instantly share code, notes, and snippets.

@datrine
Last active September 22, 2019 13:02
Show Gist options
  • Save datrine/4d93a161618036e473abf8ade290bb24 to your computer and use it in GitHub Desktop.
Save datrine/4d93a161618036e473abf8ade290bb24 to your computer and use it in GitHub Desktop.
async_callback
(cb=>{
//setTimeout() wraps the callback cb and makes it run in
//another execution context, or "thread"
//the term thread is not accurate but may provide some ease of understanding
//the different contexts that help to achieve asynchrony
setTimeout(()=>{
cb()
},0);
console.log("B")
})(()=>{
console.log("C")
});
console.log("A");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment