We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async function async1() { try { await Promise.reject('error!!!') } catch (e) { console.log(e) } console.log('async1') return Promise.resolve('async1 success') } async1().then((res) => console.log(res)) console.log('script start') // script start // error!!! // async1 // async1 success
async
try catch
async1
await
script start
try
Promise.reject('error!!!')
catch
return
.then()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Promise 6 - 1
过程讲解
async
函数后续的执行的话, 可以使用try catch
async1
执行, 遇到await
,暂停, 跳出函数.script start
try
, 遇到Promise.reject('error!!!')
,跳转到catch
去执行async1
, 执行return
.then()
输出 返回结果The text was updated successfully, but these errors were encountered: