Created
February 15, 2019 03:54
-
-
Save otarim/1634fa1994f12b15438e25112b27c75a to your computer and use it in GitHub Desktop.
microtask,macrotask
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
| async function a() { | |
| await f() | |
| console.log('a') | |
| } | |
| async function f() { | |
| console.log('f') | |
| } | |
| a() | |
| new Promise((resolve, reject) => { | |
| console.log('p') | |
| resolve() | |
| }).then(re => console.log('p1')) | |
| new Promise((resolve, reject) => { | |
| console.log('_p') | |
| resolve() | |
| }).then(re => console.log('p2')) | |
| // f p _p a p1 p2 | |
| (async function() { | |
| await a() | |
| new Promise((resolve, reject) => { | |
| console.log('p') | |
| resolve() | |
| }).then(re => console.log('p1')) | |
| new Promise((resolve, reject) => { | |
| console.log('_p') | |
| resolve() | |
| }).then(re => console.log('p2')) | |
| })() | |
| // f a p _p p1 p2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment