JS Built-ins
AsyncPatternsintermediate

Promise.race returns Promise

πŸ“– Usage Example
const first = await Promise.race([new Promise(r => setTimeout(() => r('slow'), 100)), Promise.resolve('fast')]);
// 'fast'

Promise.race() returns the result of the first promise that settles.

Promise.race()

Promise.race() returns a Promise that settles with the first Promise in the iterable.

Challenge: Verify that Promise.race() returns a Promise instance.

πŸ’‘ Hints (2)
  • β€’ Promise.race() always returns a Promise.
  • β€’ It settles with the first Promise to settle.