async函数和一般函数的区别
async函数的返回值
无论是有写返回还是没有返回值,异步函数的返回值均为Promise
let foo = async () => {
console.log('start');
console.log('end');
}
console.log(1);
const promise = foo();
console.log(2);
promise.then(res => {
console.log(res);
})
返回的promise可以使用then方法,其中的回调函数中的res就是async函数中return的值,这里的res就是undefined;
let foo = async () => {
return 666;
}
const promise = foo();
promise.then(res => {