Skip to content

About

Runnable JavaScript examples for Promise fulfillment and rejection, Promise.all, Promise.race, and async/await.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

JavaScript Promises

A small, runnable JavaScript reference for promise fulfillment and rejection, Promise.all, Promise.race, and async/await.

Features

  • Fulfillment and rejection with Error objects
  • Concurrent tasks with Promise.all, including input-order results
  • Timed Promise.race examples for both fulfillment and rejection
  • A concise async/await example
  • Simple runnable JavaScript without a framework

Run locally

node index.js

What to observe

  • Promise.all returns results in the same order as its input, even when tasks finish in a different order.
  • Promise.race settles with whichever input settles first, whether it fulfills or rejects.
  • Promise.race does not cancel the other tasks; their timers continue to run.

Further practice

  • Compare Promise.all with Promise.allSettled and Promise.any.
  • Add cancellation with AbortController to a promise-based request.
  • Change the task delays and predict the output before running the file.

Links

Support

About

Runnable JavaScript examples for Promise fulfillment and rejection, Promise.all, Promise.race, and async/await.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages