抱歉,如果这是一个非常幼稚的问题。我已将情况描述如下。我的问题是,如果 runThis()
过早返回,OtherAsyncFunction()
是否会继续并完成其执行?
var a = await runThis();
async function runThis(){
// ...
OtherAsyncFunction();
// ...
return await someOtherAsyncFunction;
}
最佳答案
它仍将执行 OtherAsyncFunction
,除非您执行 await OtherAsyncFunction()
。
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. See more details here
关于javascript - 函数返回后,另一个函数中的异步函数是否会继续运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50036058/