Ven*_*sky 2 javascript async-await es6-promise
有什么区别吗
const foo = async () => {
// some other code that uses await
return await bar()
}
Run Code Online (Sandbox Code Playgroud)
和
const foo = async () => {
// some other code that uses await
return bar()
}
Run Code Online (Sandbox Code Playgroud)
bar
返回 Promise 的函数在哪里。
这是await
多余的还是有什么区别?
这是多余的。
它从 bar 返回的 Promise 中提取值,然后foo
用它解析返回的 Promise。
如果直接返回bar
的 Promise,则 返回的 Promise 会foo
采用它,达到相同的效果。
归档时间: |
|
查看次数: |
3662 次 |
最近记录: |