Asynchronous JavaScript Promises Quiz Quiz

  1. Promise State

    What is the initial state of a Promise when it is first created?

    1. Fulfilled
    2. Rejected
    3. Pending
    4. Settled
    5. Resolved
  2. Promise Chaining

    How do you chain multiple asynchronous operations using Promises?

    1. Using nested callbacks
    2. Using the 'await' keyword
    3. By returning a new Promise in each '.then()' callback
    4. With synchronous functions
    5. By defining async variables
  3. Handling Errors

    Which method is used to handle errors in a Promise chain?

    1. .catch()
    2. .finally()
    3. .then()
    4. .error()
    5. .except()
  4. Promise.all()

    What does the Promise.all() method do?

    1. Executes promises sequentially.
    2. Resolves when all promises in an iterable have resolved or rejects when any promise rejects.
    3. Rejects when all promises in an iterable have rejected.
    4. Resolves only the fastest promise.
    5. Resolves the last promise in the iterable.
  5. Promise.race()

    What does the Promise.race() method do?

    1. Resolves when all promises in an iterable have resolved.
    2. Resolves or rejects as soon as one of the promises in an iterable resolves or rejects.
    3. Rejects when all promises in an iterable have rejected.
    4. Resolves only the slowest promise.
    5. Runs all the promises at the same time.
  6. Async/Await Syntax

    Which keyword is used to pause the execution of an async function until a Promise is resolved?

    1. pause
    2. then
    3. wait
    4. await
    5. resolve
  7. Purpose of Finally

    What is the purpose of the '.finally()' method in a Promise?

    1. To handle errors
    2. To execute code after a Promise is either resolved or rejected, regardless of the outcome
    3. To resolve the promise
    4. To chain promises together
    5. To reject the promise
  8. Fetching Data

    When using the `fetch` API, what method is typically used to extract JSON data from the response?

    1. .json()
    2. .text()
    3. .data()
    4. .parseJSON()
    5. .fromJSON()
  9. Catching Errors with Async/Await

    How should you handle errors within an `async` function?

    1. Using a '.catch()' block directly after the 'await' statement.
    2. Wrapping the 'await' statement in a try...catch block.
    3. Using a global error handler.
    4. With .error()
    5. Ignoring the error, it will be handled automatically
  10. Creating a Resolved Promise

    How do you create a Promise that is immediately resolved with a specific value?

    1. new Promise.resolve(value)
    2. Promise.create(value)
    3. Promise.resolve(value)
    4. new ResolvedPromise(value)
    5. Promise(value)