Javascript

What are the differences between Deferred Promise and Future in JavaScript

25 September 2026 · 6 min read

What are the differences between Deferred Promise and Future in JavaScript

Asynchronous programming is a cornerstone of modern JavaScript development, enabling non-blocking operations that enhance user experience and application performance. Understanding the nuances of asynchronous patterns, like Deferreds, Promises, and Futures, is crucial for writing efficient and maintainable code. This article delves into the differences between these three approaches, providing a comprehensive overview of their functionalities, use cases, and evolution within the JavaScript ecosystem.

What are Deferreds?

Deferreds, popularized by the jQuery library, represent an early approach to managing asynchronous operations in JavaScript. A Deferred object acts as a proxy for a result that is not yet available. It provides methods like .resolve() and .reject() to signal the success or failure of the asynchronous operation, and .done(), .fail(), and .always() to register callbacks that will be executed upon completion or failure. While effective, Deferreds can be verbose and lack the chaining capabilities of more modern solutions.

Consider a scenario where you need to fetch data from an external API. Using Deferreds, you would create a Deferred object, initiate the API call, and resolve or reject the Deferred based on the response. This approach allows you to handle the asynchronous nature of the API call without blocking the main thread.

Example using jQuery’s Deferred:

var deferred = $.Deferred();<br></br> $.ajax({ url: "/my-api-endpoint" }).done(function(data) {<br></br> deferred.resolve(data);<br></br> }).fail(function(error) {<br></br> deferred.reject(error);<br></br> });<br></br> deferred.done(function(data) { / Handle success / }).fail(function(error) { / Handle failure /});Understanding Promises

Promises, standardized in ES6 (ECMAScript 2015), offer a more streamlined and powerful approach to asynchronous programming. A Promise represents the eventual result of an asynchronous operation. Unlike Deferreds, where callbacks are attached separately, Promises use the .then() method for chaining operations and handling both success (resolve) and failure (reject) scenarios using .catch(). This chained structure enhances code readability and maintainability.

Fetching data from an API using Promises becomes significantly more concise:

fetch("/my-api-endpoint")<br></br> .then(response => response.json())<br></br> .then(data => { / Handle success / })<br></br> .catch(error => { / Handle failure / });The clear chaining of .then() calls makes the flow of asynchronous operations easier to follow and reason about, improving code clarity and reducing the risk of errors. This structured approach is a significant advantage over Deferreds.

Exploring Futures (Async/Await)

Async/Await, introduced in ES8 (ECMAScript 2017), builds upon Promises, providing a syntax that makes asynchronous code look and behave more like synchronous code. By using the async keyword before a function, you enable the use of await, which pauses the execution of the function until the Promise it’s awaiting resolves or rejects. This synchronous-like style further simplifies asynchronous code, making it even easier to read and debug.

The same API call example using Async/Await:

async function fetchData() {<br></br> try {<br></br> const response = await fetch("/my-api-endpoint");<br></br> const data = await response.json();<br></br> // Handle success with data<br></br> } catch (error) {<br></br> // Handle failure<br></br> }<br></br> }<br></br> Async/Await makes asynchronous code remarkably similar to synchronous code, drastically improving readability and simplifying complex asynchronous logic.

Key Differences and Use Cases

While Deferreds, Promises, and Futures serve a similar purpose, their implementations and capabilities differ. Deferreds are an older pattern, largely superseded by Promises. Promises offer a standardized, chainable approach, simplifying asynchronous code management. Futures (Async/Await) enhance Promises further, introducing a synchronous-like syntax for even greater clarity.

  • Deferreds: Primarily used in older jQuery codebases. Consider migrating to Promises for better maintainability.
  • Promises: The standard for modern JavaScript asynchronous programming. Use for handling asynchronous operations in a clean, chainable manner.
  • Futures (Async/Await): The preferred approach for writing clean, readable asynchronous code that resembles synchronous code. Best for complex asynchronous logic.

Choosing the right approach depends on the project’s context and existing codebase. However, for new projects, Async/Await with Promises is generally recommended for its clarity and maintainability. For instance, in a single-page application (SPA), fetching data from multiple APIs can be elegantly handled using Async/Await.

![Infographic comparing Deferreds, Promises, and Futures]([infographic placeholder])

Dive deeper into the evolution of asynchronous JavaScript: MDN Async/Await Documentation.

Explore how Promises are implemented: Promises/A+ Specification

Learn more about the intricacies of asynchronous JavaScript: Mastering Async/Await in Node.js

By understanding the distinctions between Deferreds, Promises, and Futures, you can write more efficient, readable, and maintainable JavaScript code, leveraging the full power of asynchronous programming. Embrace the elegance of Async/Await for new projects, and consider refactoring older codebases to utilize Promises for enhanced clarity.

For further insights into JavaScript development, explore our resources on advanced JavaScript concepts and best practices: Learn More

  1. Evaluate your project’s needs and choose the appropriate asynchronous pattern.
  2. For new projects, prioritize Async/Await with Promises.
  3. Refactor legacy code using Deferreds to utilize Promises.

FAQ

Q: What is the main advantage of using Async/Await?

A: Async/Await makes asynchronous code look and behave a lot like synchronous code, making it easier to read, write, and debug. It builds upon Promises, providing a more elegant and readable syntax for complex asynchronous operations.

Question & Answer :
What are the differences between Deferreds, Promises and Futures?
Is there a generally approved theory behind all these three?

These answers, including the selected answer, are good for introducing promises conceptually, but lacking in specifics of what exactly the differences are in the terminology that arises when using libraries implementing them (and there are important differences).

Since it is still an evolving spec, the answer currently comes from attempting to survey both references (like wikipedia) and implementations (like jQuery):

  • Deferred: Never described in popular references, 1 2 3 4 but commonly used by implementations as the arbiter of promise resolution (implementing resolve and reject). 5 6 7

    Sometimes deferreds are also promises (implementing then), 5 6 other times it’s seen as more pure to have the Deferred only capable of resolution, and forcing the user to access the promise for using then. 7

  • Promise: The most all-encompasing word for the strategy under discussion.

    A proxy object storing the result of a target function whose synchronicity we would like to abstract, plus exposing a then function accepting another target function and returning a new promise. 2

    Example from CommonJS:

    > asyncComputeTheAnswerToEverything() .then(addTwo) .then(printResult); 44 
    

    Always described in popular references, although never specified as to whose responsibility resolution falls to. 1 2 3 4

    Always present in popular implementations, and never given resolution abilites. 5 6 7

  • Future: a seemingly deprecated term found in some popular references 1 and at least one popular implementation, 8 but seemingly being phased out of discussion in preference for the term ‘promise’ 3 and not always mentioned in popular introductions to the topic. 9

    However, at least one library uses the term generically for abstracting synchronicity and error handling, while not providing then functionality. 10 It’s unclear if avoiding the term ‘promise’ was intentional, but probably a good choice since promises are built around ’thenables.’ 2

References

  1. Wikipedia on Promises & Futures
  2. Promises/A+ spec
  3. DOM Standard on Promises
  4. DOM Standard Promises Spec WIP
  5. DOJO Toolkit Deferreds
  6. jQuery Deferreds
  7. Q
  8. FutureJS
  9. Functional Javascript section on Promises
  10. Futures in AngularJS Integration Testing

Misc potentially confusing things