//1
async function f() {
return 'hello world';
}
f().then(res => console.log(res))
//2
async function f() {
return await 'hello world';
}
f().then(res => console.log(res))
写法一和写法二有啥区别
//1
async function f() {
return 'hello world';
}
f().then(res => console.log(res))
//2
async function f() {
return await 'hello world';
}
f().then(res => console.log(res))
写法一和写法二有啥区别
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
4 回答2.2k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
3 回答838 阅读✓ 已解决
2 回答2k 阅读✓ 已解决
5 回答2.3k 阅读
没区别,如果
await
后面的表达式不是一个Promise
,则返回该值本身