首页 > 试题广场 >

下面的代码使用了 asyncawait,选择输出结果是什么

[单选题]
下面的代码使用了 async/await,选择输出结果是什么?
function delay(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
async function delayedGreeting() {
    console.log("Start");
    await delay(1000);
    console.log("Hello!");
    console.log("End");
}
delayedGreeting();


  • Start, Hello!, End
  • Start, End, Hello!
  • Hello!, Start, End
  • End, Start, Hello!
这题是不是设计有问题,插入再多Promise或者await也不改变语句的执行顺序啊
发表于 2025-11-04 19:24:05 回复(0)