- Mastering JavaScript Promises
- Muzzamil Hussain
- 161字
- 2021-07-16 13:46:45
Why do we need promise in JS?
Promises.js is a JavaScript library that promises asynchronous I/O operations such as reading and writing on a file. Whenever there is a callback method that involves making all operations related to I/O, they are to be made asynchronous. This extra callback parameter confuses our idea of what is the input and what will be its return value. It never works with control flow primitives. It also doesn't handle errors thrown by a callback method.
So, we need to handle errors thrown by a callback method, but also need to be careful not to handle errors thrown by the callback method. By the time we are done with this, our code will be a mess of error handling.
Despite all this mess of error handling code, we are still left with the problem of the extra callback parameter hanging around. Promises help you naturally handle errors, and write cleaner code by not having callback parameters.
- Microsoft Exchange Server PowerShell Cookbook(Third Edition)
- Learning ROS for Robotics Programming(Second Edition)
- 零基礎PHP學習筆記
- Learning Data Mining with Python
- 區塊鏈:以太坊DApp開發實戰
- Access 2010數據庫應用技術(第2版)
- Android應用案例開發大全(第二版)
- Spring+Spring MVC+MyBatis從零開始學
- Java Web應用開發給力起飛
- 實驗編程:PsychoPy從入門到精通
- Python全棧開發:數據分析
- JavaScript編程精解(原書第3版)
- jBPM6 Developer Guide
- Kotlin入門與實戰
- JavaScript程序設計實例教程(第2版)