Skip to content

Instantly share code, notes, and snippets.

@patrickhulce
Created December 18, 2017 22:02
Show Gist options
  • Save patrickhulce/fd726acd1431b137941f1eff4fba1f2e to your computer and use it in GitHub Desktop.
Save patrickhulce/fd726acd1431b137941f1eff4fba1f2e to your computer and use it in GitHub Desktop.
See scheduling of callbacks/microtasks/tasks
(() => {
console.log('script start');
setTimeout(function() {
console.log('setTimeout');
}, 0);
// Edge/IE only
// setImmediate(function() {
// console.log('setImmediate');
// });
Promise.resolve().then(function() {
console.log('promise1');
}).then(function() {
console.log('promise2');
});
console.log('script end');
const evt = new Event('test')
const evtListener = () => console.log('click handler')
document.addEventListener('test', evtListener)
document.dispatchEvent(evt)
document.removeEventListener('test', evtListener)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment