Skip to content

Instantly share code, notes, and snippets.

@nem035
Last active October 18, 2018 16:12
Show Gist options
  • Select an option

  • Save nem035/ec1e6038d55bd792a08b359641d07858 to your computer and use it in GitHub Desktop.

Select an option

Save nem035/ec1e6038d55bd792a08b359641d07858 to your computer and use it in GitHub Desktop.
console.log("first");
// enqueue a Task after this Task
setTimeout(function() {
console.log("fourth");
}, 0);
// enqueue a microtask within this Task
Promise.resolve()
// enqueue a microtask after this microtask
.then(function() {
console.log("second");
})
// enqueue a microtask after this microtask
.then(function() {
console.log("third");
});
// output: 'first' 'second' 'third' 'fourth'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment