Crack the Code: Easy Async JavaScript Interview Questions Quiz

  1. Understanding Debounce

    What does the 'debounce' function help prevent when handling events such as typing in a search bar?

    1. It delays the execution of a function until a certain time has passed without any new events.
    2. It runs a function immediately as soon as an event is triggered.
    3. It repeats a function multiple times in quick succession.
    4. It cancels the latest function call only, keeping older ones.
    5. It reverses the order of all incoming function calls.
  2. Promise.race Behavior

    Given several asynchronous operations, what does 'Promise.race' return when used with them?

    1. It resolves or rejects with the result of the first promise to settle.
    2. It returns an array of all resolved values.
    3. It waits for all promises to resolve.
    4. It only returns if all promises reject.
    5. It cancels all other promises except the last one.
  3. Promise Merge Understanding

    If you need to combine the results of two promises into one object, which concept describes this process?

    1. Promise Merge
    2. Promise Error
    3. Promise Fail
    4. Promise Resolve
    5. Promise Delay
  4. Function of Promise.all

    Which statement best describes what 'Promise.all' does with an array of promises?

    1. It resolves when all of the promises resolve, returning an array of their results.
    2. It rejects as soon as the slowest promise fails.
    3. It resolves with the first resolved promise's value.
    4. It ignores rejected promises and only returns resolved ones.
    5. It executes promises one after another in sequence.
  5. Features of Promise.allSettled

    When using 'Promise.allSettled', what happens if some promises are rejected?

    1. It waits for all promises to settle, then returns the outcome of each in an array.
    2. It immediately rejects with the first rejected promise.
    3. It only returns the results of fulfilled promises.
    4. It retries any promise that is rejected.
    5. It cancels any remaining unsettled promises.
  6. Handling Promise Timeouts

    Suppose you want a promise to reject if it takes longer than 2 seconds to resolve. What is this mechanism called?

    1. Promise Timeout
    2. Promise Reorder
    3. Promise Cascade
    4. Promise Hold
    5. Promise Handler
  7. Promise.any Usage

    If you use 'Promise.any' on several promises, what will the result be if only one of those promises resolves?

    1. It resolves as soon as any promise fulfills, with that promise's value.
    2. It rejects as soon as any promise rejects.
    3. It only resolves if all promises succeed.
    4. It waits until all promises are rejected.
    5. It cancels all pending promises immediately.
  8. Understanding Promisify

    What does 'promisify' do with a traditional callback-based function?

    1. It converts the function so that it returns a promise.
    2. It makes the function run synchronously.
    3. It merges multiple callbacks into one.
    4. It delays the function execution by a set time.
    5. It runs the callback twice for reliability.
  9. Purpose of Throttle

    When would you use a 'throttle' function in user interface code?

    1. To limit how often a function like window resize is called, even if the event fires rapidly.
    2. To double the number of function executions.
    3. To trigger a function only after an event has stopped completely.
    4. To ignore the first event and only handle later ones.
    5. To randomly delay function execution by a few milliseconds.
  10. Lazy Man Implementation

    In a 'Lazy Man' design, which behavior does the object typically exhibit?

    1. It chains together asynchronous actions so they execute in a specific order.
    2. It processes all actions in parallel immediately.
    3. It ignores all chained actions except the first.
    4. It cancels any previously scheduled actions.
    5. It randomly decides which actions to perform next.