Created
August 15, 2024 19:26
-
-
Save fzn0x/b2b9e24557af86e683f3c5376220ae04 to your computer and use it in GitHub Desktop.
After Synchronous Loop inside the Event Loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const afterSynchronousLoop = | |
queueMicrotask || | |
setImmediate || | |
(function () { | |
if (Promise) { | |
return function (fn) { | |
Promise.resolve().then(fn); | |
}; | |
} | |
return function (fn) { | |
setTimeout(fn, 0); | |
}; | |
})(); | |
afterSynchronousLoop(() => console.log("Hello, World!")); | |
console.log("Goodbye, World!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment