Created
April 21, 2018 07:40
-
-
Save kurogelee/7d5c40aa3a5186f141059ad746a5c5b6 to your computer and use it in GitHub Desktop.
async/await, Promiseの実行順序 ref: https://qiita.com/kurogelee/items/21042b3c0a523bd90e5d
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 log = console.log; | |
async function f0() { | |
return "ZZZ"; | |
} | |
async function f1() { | |
await f0(); | |
return "XXX"; | |
} | |
log(1); | |
new Promise(async (resolve) => { | |
resolve(); | |
log(2); | |
await f0(); | |
// await f1(); | |
log(3); | |
}).then((value) => { | |
log(4); | |
}); | |
(async () => { | |
log(5); | |
await f0(); | |
// await f1(); | |
log(6); | |
})(); | |
log(7); |
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
1 | |
2 | |
5 | |
7 | |
4 | |
3 | |
6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment