Created
January 9, 2020 15:31
-
-
Save ryanhanwu/959ef94087e6b75ea7d2f4f491785a33 to your computer and use it in GitHub Desktop.
Promise + Async/Await Test1
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
console.log(1); | |
(async () => { | |
const promiseF = new Promise((resolve, reject) => { | |
console.log(2) | |
setTimeout(()=>{ | |
try { | |
console.log(3) | |
resolve() | |
console.log(4) | |
} catch (error) { | |
console.log(5) | |
reject(error) | |
} | |
}, 0) | |
console.log(6) | |
}); | |
const result = await promiseF.then(()=>{ | |
console.log(7) | |
return Promise.resolve('Hello') | |
}) | |
console.log(result) | |
})() | |
console.log(8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment