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

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.

主站蜘蛛池模板: 安新县| 开原市| 柯坪县| 图片| 鹤庆县| 灌南县| 肃北| 云梦县| 色达县| 斗六市| 罗山县| 西和县| 泗洪县| 榆树市| 安化县| 阳原县| 盐池县| 九龙城区| 姜堰市| 阜阳市| 巴林右旗| 石狮市| 肥东县| 剑河县| 营山县| 安龙县| 新安县| 铜陵市| 耿马| 临猗县| 阳西县| 岚皋县| 雷山县| 株洲市| 晋中市| 那坡县| 万全县| 年辖:市辖区| 崇州市| 临泽县| 宣城市|