- 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.
- Google Flutter Mobile Development Quick Start Guide
- Python從小白到大牛
- Mastering Ember.js
- Java高手真經(jīng)(高級(jí)編程卷):Java Web高級(jí)開發(fā)技術(shù)
- 劍指MySQL:架構(gòu)、調(diào)優(yōu)與運(yùn)維
- Android開發(fā)案例教程與項(xiàng)目實(shí)戰(zhàn)(在線實(shí)驗(yàn)+在線自測)
- Learning jQuery(Fourth Edition)
- .NET 4.5 Parallel Extensions Cookbook
- RubyMotion iOS Develoment Essentials
- Emotional Intelligence for IT Professionals
- MongoDB Cookbook
- Node.js應(yīng)用開發(fā)
- Spring Boot從入門到實(shí)戰(zhàn)
- 用Go語言自制編譯器
- Java Web應(yīng)用開發(fā)