Last active
January 15, 2023 16:24
-
-
Save zhanglintc/4f800060dcf7dc0b6852657914760223 to your computer and use it in GitHub Desktop.
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
function heavyTask() { | |
i=0 | |
// do a heavy job | |
for (let j = 0; j < 1e8; j++) { | |
i++; | |
} | |
} | |
setTimeout(function(){console.log(1)}, 10) | |
heavyTask(); | |
setTimeout(function(){console.log(2)}, 0) | |
// Chrome: | |
// 2 | |
// 1 | |
// Node.js: | |
// 1 | |
// 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment