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结点直接返回。