官术网_书友最值得收藏!

Callback, revisited

In previous chapters, you learned how the JavaScript mechanism works. The single-threaded model of JavaScript has its limitation, which can be controlled through better use of callbacks. However, the scenarios such as callback hell really pushed engineers to find and implement a better way to control the callbacks and maximize the performance of the program, while staying inside a single thread. A callback is a function that can be passed as an argument to another function to be executed when it's called.

There is absolutely no harm in using callbacks, but there are also a number of other options available to handle asynchronous events. Promise is one such way to handle asynchronous events and has more efficiency than many of other asynchronous tools in its family.

To understand more clearly why we needed to implement Promises.js in asynchronous programming, we need to understand the concept behind the promise and deferred objects.

主站蜘蛛池模板: 巍山| 宝丰县| 中阳县| 精河县| 济宁市| 马山县| 娱乐| 镶黄旗| 浮山县| 嘉兴市| 句容市| 灵宝市| 竹溪县| 平远县| 宜阳县| 涡阳县| 涡阳县| 玉林市| 肥城市| 绥中县| 沧州市| 邢台市| 岚皋县| 云安县| 九江市| 宜兰市| 监利县| 临潭县| 高安市| 青河县| 浦县| 庆安县| 天镇县| 株洲县| 西和县| 偏关县| 安义县| 油尖旺区| 黄冈市| 溆浦县| 桑植县|