您的浏览器需要启用 JavaScript 才能正常访问此网站。
Hotline:15911225507
Long Xiao
Login
Home-All Questions-Javascript-Main Content

async和await的优势

LXLXJavascript3 years ago001.98K

Promise能够解决回调函数的层层嵌套问题,但是then()链阅读起来会增加额外负担,而async和await就非常明确,更加优雅。

Promise传递中间值非常麻烦,而async和await代码几乎上是同步的,非常优雅。

Promise很难不哦去到错误,而async和await能够使用成熟的try..catch进行捕获错误。

Promise代码很难进行调试,而async的调试很好

LX

LX

Lv1Rec2
Revitalize the WordPress experience with the power of Nuxt.js
From: Course-JavaScript 教程
119
Loading...
Share:
Long Xiao
No answers yet, be the first?
我要回答
Accepted answer rewards 100 points
Long Xiao
Please login first