javaScript中的重要承诺。。。。。。

Important of Promises in javaScript......
2023-01-06 05:03:31
JavaScript Programming Blogs hashnode

Defination - Promises are used to handle asynchronous operations. The promise object represent the eventual completion or failure.

Benefit of Promises- 1.Improves code reusability. 2.Better error handling.

Example -

Screenshot (37).png

Output -

Screenshot (38).png

States of promises - 1.Pending = Initial State. 2.Fulfilled = Operation completed. 3.Rejected = Operation Failed

© 2022 开源博客 京ICP备20030565号-2 Powered by Quick API team