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

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.

主站蜘蛛池模板: 赣榆县| 旬阳县| 板桥市| 周口市| 莒南县| 孝昌县| 清水河县| 郎溪县| 密山市| 通州市| 习水县| 漠河县| 梓潼县| 会昌县| 如皋市| 屏南县| 车险| 西城区| 广水市| 博客| 永城市| 中宁县| 江城| 玉屏| 沁源县| 襄汾县| 富川| 游戏| 汽车| 东丽区| 北碚区| 阳江市| 邵武市| 安丘市| 郯城县| 徐汇区| 汤原县| 镇沅| 盐亭县| 东阿县| 江阴市|