<script type="text/javascript">
async function foo(){
return new Promise(resolve =>{
setTimeout(function(){
console.log(111);
resolve();
},2000);
})
}
async function test(){
console.log('开始',new Date().toTimeString());
await foo();
// foo();
console.log('完毕',new Date().toTimeString());
}
test();
</script>
通过分别执行await foo()与foo(),来观察控制台显示即可;