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

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.

主站蜘蛛池模板: 中方县| 云霄县| 永昌县| 奈曼旗| 保定市| 鸡泽县| 浙江省| 黔东| 浠水县| 昌图县| 苍溪县| 正定县| 禄丰县| 长丰县| 新源县| 湖南省| 偏关县| 潮州市| 黄大仙区| 长寿区| 博乐市| 故城县| 普洱| 博野县| 崇仁县| 十堰市| 余姚市| 奉新县| 金昌市| 青铜峡市| 天祝| 磐安县| 洪江市| 永福县| 太康县| 南漳县| 汶上县| 太仓市| 安远县| 龙井市| 都昌县|