Skip to content

Instantly share code, notes, and snippets.

@ryanhanwu
Created January 9, 2020 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanhanwu/959ef94087e6b75ea7d2f4f491785a33 to your computer and use it in GitHub Desktop.
Save ryanhanwu/959ef94087e6b75ea7d2f4f491785a33 to your computer and use it in GitHub Desktop.
Promise + Async/Await Test1
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