Created
February 21, 2018 08:22
-
-
Save ryuheechul/c9234012e2801efe284f5ae20b1c7c5b to your computer and use it in GitHub Desktop.
an example of no concurrency in JS Promise
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
function printTo100(n) { | |
for (i in [...Array(100).keys()]){ | |
console.log(`${n}-${i}`) | |
} | |
return Promise.resolve() | |
} | |
Promise.all( | |
printTo100('a'), | |
printTo100('b'), | |
printTo100('c'), | |
printTo100('d'), | |
printTo100('e'), | |
printTo100('f') | |
) | |
// The result is aaa...bbb...ccc not abcabcabc... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop