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关键字做了什么:
async
async function fn() { return 'async111'; } const p = fn(); console.log(p); // Promise {<resolved>: "async111"} (返回一个状态为resolved,值为async111的Promise实例) // 等价于 function fn1(){ return Promise.resolve('async111'); } const p1 = fn1(); console.log(p1); // Promise {<resolved>: "async111"}
简单总结一下对于 await v:
await v
fulfilled
resolved(v)
then()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
async函数的返回值
async
关键字做了什么:await操作符做了什么
简单总结一下对于
await v
:fulfilled
的Promise,还是会新建一个Promise,并在这个新Promise中resolved(v)
await v
后续的代码的执行类似于传入then()
的回调。The text was updated successfully, but these errors were encountered: