Created
March 28, 2024 07:55
-
-
Save Etc3tera/eeff334718adde9dd32c683a858d60e7 to your computer and use it in GitHub Desktop.
explain JS single thread
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
message = 'aha' | |
setTimeout(() => { | |
message = 'happy'; | |
}, 1) | |
setTimeout(() => { | |
console.log('2nd setTimeout: ' + message) | |
}, 500) | |
console.log('start: ' + new Date().toISOString()) | |
x = 0 | |
for(let i = 0; i < 500; i++) { | |
for(let j = 0; j < 1000000; j++) { | |
x = Math.random() | |
} | |
} | |
console.log('end: ' + new Date().toISOString()) | |
console.log(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment