Created
January 28, 2022 08:28
-
-
Save remy727/3303a0ffc8ef4f48e94d3fe3346c0d68 to your computer and use it in GitHub Desktop.
JavaScript Event Loop
This file contains 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
setTimeout(() => console.log(1), 100) | |
setTimeout(() => console.log(2), 0) | |
Promise.resolve(42).then(() => { | |
console.log(3); | |
setTimeout(() => console.log(4), 50); | |
}) | |
.then(() => Promise.reject(new Error(22))) | |
.then(() => console.log(5)) | |
.catch((e) => console.log(6, e.message)) | |
console.log(7) | |
// answers: | |
7 | |
3 | |
6 22 | |
2 | |
4 | |
1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment