On this page
  1. Promise.race
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

Promise.race

Prev: allSettled | Up: Promise | Next: any
Rel: Promise, Promise & Async Guide
Ref: MDN Web Docs — Promise.race
Tags: #public #web #javascript #builtins #promise #tier/standard


Signature & Overview

Promise.race(iterable)

Settles (fulfills or rejects) with the first promise in iterable that settles.

Notes & Pitfalls

Example

const fastest = await Promise.race([
  Promise.resolve("instant"),
  new Promise((r) => setTimeout(() => r("slow"), 50)),
]);
console.assert(fastest === "instant");

Linked from

Related notes