Skip to content

Instantly share code, notes, and snippets.

@shikelong
Created March 14, 2022 14:32
Show Gist options
  • Save shikelong/06ed03d68332d343c0c42c551374be5a to your computer and use it in GitHub Desktop.
Save shikelong/06ed03d68332d343c0c42c551374be5a to your computer and use it in GitHub Desktop.
Event Loop Test Codes
console.group('output 🌿')
queueMicrotask(() => {
console.log('queueMicrotask')
});
requestAnimationFrame(() => {
console.log('requestAnimationFrame')
})
requestIdleCallback(() => {
console.log('requestIdleCallback')
})
new Promise((res) => {
console.log('promise executor');
res(100)
}).then((n) => {
console.log('promise call back: ', n)
})
setTimeout(() => {console.log('setTimeout'); queueMicrotask(() => {
console.log('queueMicrotask2...')
})}, 0)
console.log('---sync----')
console.groupEnd('output 🌿')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment