Promises Made Easy: Interview Basics - Part 7 Quiz

  1. Understanding Promise.all

    What does the method Promise.all return if passed an array of multiple pending promises?

    1. A single promise that resolves when all input promises resolve
    2. A single promise that rejects immediately
    3. Each promise in an array
    4. The value of the fastest promise
    5. A function to cancel all promises
  2. Behavior of Promise.race

    Given Promise.race([p1, p2]), what does the resulting promise resolve or reject with?

    1. The outcome of the first settled promise in the array
    2. The result of the last promise
    3. The sum of all resolved values
    4. An array of all promises
    5. An error if any promise fails
  3. Purpose of Promise.allSettled

    If you use Promise.allSettled with promises that both resolve and reject, what is returned?

    1. An array of objects that each describe the outcome of every promise
    2. A rejected promise overall
    3. The resolved value of the first successful promise
    4. A string indicating success or failure
    5. Nothing is returned
  4. Promise.any Method

    What does Promise.any([p1, p2, p3]) resolve with if p2 resolves first?

    1. The value that p2 resolves with
    2. The value that the last promise resolves with
    3. The value from the fastest rejected promise
    4. An array of all resolved values
    5. It always rejects
  5. Settling Behavior in Promise.all

    If one of the promises passed to Promise.all rejects, what happens?

    1. Promise.all immediately rejects with that error
    2. Promise.all waits for all promises then resolves
    3. It continues with remaining promises
    4. It skips the rejected promise
    5. Returns undefined
  6. Order of Results in Promise.all

    If you pass [p1, p2, p3] to Promise.all, what is the order of resolution values in the result?

    1. The order matches the original promise array
    2. Random order depending on which resolves first
    3. Sorted by resolved values
    4. Reverse order from the array
    5. Only the first resolved value
  7. Promise.resolve Utility

    Which statement accurately describes Promise.resolve(5)?

    1. It returns a promise that immediately resolves with 5
    2. It returns a promise that never settles
    3. It throws an error with value 5
    4. It rejects the promise with value 5
    5. It returns 5
  8. Promise.reject Behavior

    What does Promise.reject('fail') return?

    1. A promise that immediately rejects with 'fail'
    2. A resolved value of 'fail'
    3. A function that throws 'fail' later
    4. Nothing is returned
    5. A string 'fail'
  9. Promise.allSettled Edge Case

    If Promise.allSettled receives an empty array, what does it return?

    1. A promise resolved with an empty array
    2. A rejected promise
    3. null
    4. A pending promise forever
    5. An error is thrown
  10. Difference between Promise.all and Promise.race

    How does Promise.race differ from Promise.all when given multiple promises?

    1. Promise.race settles as soon as the first promise settles, while Promise.all waits for all
    2. Promise.all rejects for any promise, while Promise.race only resolves
    3. Promise.race only accepts resolved promises
    4. Promise.all returns a single value but Promise.race returns an array
    5. Promise.race is slower than Promise.all