Chapter 10Keeping Your Promises
Asynchronous programming is a way of life in JavaScript. Unless a method returns instantaneously, we should never call it with the intention of waiting for a response. Most functions in JavaScript libraries and frameworks are asynchronous. Although making a call and getting the results later is not new in JavaScript, the mechanics of this have evolved over the past few years.
The traditional approach to asynchronous programming was to use callbacks. Unfortunately, as we’ll soon discuss, there are many issues with callbacks. In modern JavaScript, promises replace callbacks for asynchronous programming. A code that returns a promise is nonblocking and will eventually return a result or an error to the caller through ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access