关于async和await的问题,大概想了一下原因,但是不知道是否正确,有没有同学来一起探讨一下这个问题
let x = 0;
async function test() {
x = (await test1())+x;
console.log(x);
}
async function test1() {
return 2
}
test();
x = 1;
打印结果是3,这个很容易理解
let x = 0;
async function test() {
x =x+ await test1();
console.log(x);
}
async function test1() {
return 2
}
test();
x = 1;
打印结果是2,这个怎么理解