Javascript Promises

javascript - printed - printed - printed - printed - printed - printed - printed

What is a promise?
Special case 1 / setTimeout
How can we use Promise.all(iteratable)?
How can we use Promise.race(iteratable)
Using promises to tame setTimeout
How can we timeout a promise?
How can we delay execution of the next promise in a chain?

  1. What happens if we have an existing promise and we pass this promise to Promise.resolve or Promise.reject? Will it resolve or reject the original promise? My guess is that it will not resolve or reject the original promise, but what will happens to all those then callbacks or catch callbacks?
  2. Promise.all returns a promise that is rejected as soon as one of the promises is rejected. If we need to waits for all promises to be either resolved or rejected, how can we do this?
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License