An async
function can contain an await
expression that pauses the execution of the async function and waits for the passed Promise
's resolution, and then resumes the async
function's execution and returns the resolved value.
Remember, the await
keyword is only valid inside async
functions. If you use it outside of an async
function's body, you will get a SyntaxError
.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
async 函數的調用方式:
await調用:同步調用;
常規調用:遇到內部await結點直接返回。