Javascript Await/Async Feature - What if you do not have the await word in the function?

前端 未结 3 812
轮回少年
轮回少年 2021-01-27 18:37

I am learning about Javascript ES2017 async/await feature. Been reading a lot about it, and came across an understanding that await is like yield, and allows us to wait for the

3条回答
  •  不知归路
    2021-01-27 19:06

    First, async / await, work with promises. If you are not calling from an async function or the await sentence is not then compatible, it won't work. In most cases if you remove await, you are going to end with a Promise and not the value of the promise.

    Secondly, there are some cases that you may want to continue with the execution of the code while you are resolving some asynchronous task.

提交回复
热议问题