ES6的异步 async promise
执行下面的代码,得到的结果是什么
start
p1_3000
p2_1000
end
结束
<script> function p1(){ return new Promise(function(resolve,reject){ setTimeout(function(){ console.log("p1_3000"); resolve(); },3000) }) } function p2(){ return new Promise(function(resolve,reject){ setTimeout(function(){ console.log("p2_1000"); resolve(); },1000) }) } //await 只能出现在异步函数里 async function process(){ console.log("start"); await p1(); await p2(); console.log("end"); } p3 = process(); p3.then(function(){ console.log("结束"); }); </script>