Deferreds and promises
jQuery deferred objects were introduced at a time when there was no consistent way to handle asynchronous behavior in JavaScript code. Promises help us orchestrate asynchronous stuff, such as multiple HTTP requests, file reads, animations, and so on. Promises aren't exclusive to JavaScript, nor are they a new idea. The best way to think about a promise is as a contract that promises to resolve a value eventually.
Now that promises are officially part of JavaScript, jQuery now fully supports promises. That is, jQuery deferred objects behave just like any other promise. This is important, as we'll see in this section, because it means that we can use jQuery deferreds to compose complex asynchronous behavior with other ...
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