有什么区别吗
const foo = async () => {
// some other code that uses await
return await bar()
}
和
const foo = async () => {
// some other code that uses await
return bar()
}
哪里bar
是一个返回 promise 的函数。
是 await
多余还是有什么区别?
最佳答案
这是多余的。
它从 bar 返回的 Promise 中提取值,然后用它解析 foo
返回的 Promise。
如果直接返回 bar
的 Promise,则 foo
返回的 Promise 会采用它达到相同的效果。
关于javascript - "return await"有什么区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71069139/