async和await的使用html
async 異步執行
用法:異步
async function name () { return 'hello' } console.log(name()) console.log('world')
async 後面的函數的執行不會阻礙後面console的執行,兩個語句是同時執行的。async
await 同步執行
用法:函數
await function name () { return 'hello' } console.log(name()) console.log('world')
await 後面的函數執行完了才能執行後面的語句。code