有什么区别吗
const foo = async () => {
// some other code that uses await
return await bar()
}
and
const foo = async () => {
// some other code that uses await
return bar()
}
Where bar
是一个返回承诺的函数。
Is the await
多余还是有什么区别?
这是多余的。
它从 bar 返回的 Promise 中提取值,然后解析由 Bar 返回的 Promisefoo
用它。
如果你回来bar
直接的promise,然后返回的promisefoo
采用它可以达到同样的效果。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)