Async/await promise实现

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

猜你喜欢

转载自www.cnblogs.com/feng9exe/p/11207115.html
今日推荐