async await练习随笔
(function(){ /* async function timeout(){ return "hello async"; } timeout().then(result => { console.log(result); }) //console.log(timeout()); async function asyncFn() { return "我后执行"; }; asyncFn().then(result => { console.log(result); }) console.log("先执行"); //async会被定义为异步函数,不会影响后面正常的执行。 async function test() { throw new Error("it's error"); }; test().then(success => console.log('成功了',success)) .catch(error => console.log("失败了",error)); async function throwStatus() { return "show all"; }; throwStatus().then(success => console.log("成功",success)) .catch(error => console.log("失败",error)); async