JavaScript Promises

Introduction

A Promise[fn:footnote] is an asynchronous action that may complete at some point and produce a value. It is able to notify anyone who is interested when its value is available.

let fifteen = Promise.resolve(15);
fifteen.then(value => console.log(`Got ${value}`))

Parallel

  • [Executing Promises in Parallel (Promises.all)](Executing Promises in Parallel (Promises.all))
  • Promise.allSettled

Errors

  • [Catching Promise Errors](Catching Promise Errors)
  • [JavaScript Promises Finally](JavaScript Promises Finally)

Producing & Consuming

Use [JavaScript Async Functions](JavaScript Async Functions) instead of this.

  • [Producing Promises](Producing Promises)
  • [JavaScript Consuming Promises](JavaScript Consuming Promises)

Footnotes

[fn:footnote]https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Promise