javascript - 函数返回后,另一个函数中的异步函数是否会继续运行?

标签 javascript async-await

抱歉,如果这是一个非常幼稚的问题。我已将情况描述如下。我的问题是,如果 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/

相关文章:

javascript - 隐藏某些用户的评论?

javascript - 是否可以在没有 return 关键字的情况下解析异步函数

javascript - 如何正确实现 async/await

c# - 当有数百个 Task.Delay 时性能如何

node.js - 如何异步使用jest.each

javascript - 在 ajax 调用不起作用后 Yii 从 Controller 操作重定向

javascript - 如何在javascript中对小数进行四舍五入和求和?

javascript - 将 html5 canvas 元素保存到文件(本地)

javascript - 带有渲染回调函数的 jQuery 数据表问题

c# - 异步等待、异常处理和继续使用 TaskContinuationOptions.OnlyOnFaulted