Understanding Debounce
What does the 'debounce' function help prevent when handling events such as typing in a search bar?
- It delays the execution of a function until a certain time has passed without any new events.
- It runs a function immediately as soon as an event is triggered.
- It repeats a function multiple times in quick succession.
- It cancels the latest function call only, keeping older ones.
- It reverses the order of all incoming function calls.
Promise.race Behavior
Given several asynchronous operations, what does 'Promise.race' return when used with them?
- It resolves or rejects with the result of the first promise to settle.
- It returns an array of all resolved values.
- It waits for all promises to resolve.
- It only returns if all promises reject.
- It cancels all other promises except the last one.
Promise Merge Understanding
If you need to combine the results of two promises into one object, which concept describes this process?
- Promise Merge
- Promise Error
- Promise Fail
- Promise Resolve
- Promise Delay
Function of Promise.all
Which statement best describes what 'Promise.all' does with an array of promises?
- It resolves when all of the promises resolve, returning an array of their results.
- It rejects as soon as the slowest promise fails.
- It resolves with the first resolved promise's value.
- It ignores rejected promises and only returns resolved ones.
- It executes promises one after another in sequence.
Features of Promise.allSettled
When using 'Promise.allSettled', what happens if some promises are rejected?
- It waits for all promises to settle, then returns the outcome of each in an array.
- It immediately rejects with the first rejected promise.
- It only returns the results of fulfilled promises.
- It retries any promise that is rejected.
- It cancels any remaining unsettled promises.
Handling Promise Timeouts
Suppose you want a promise to reject if it takes longer than 2 seconds to resolve. What is this mechanism called?
- Promise Timeout
- Promise Reorder
- Promise Cascade
- Promise Hold
- Promise Handler
Promise.any Usage
If you use 'Promise.any' on several promises, what will the result be if only one of those promises resolves?
- It resolves as soon as any promise fulfills, with that promise's value.
- It rejects as soon as any promise rejects.
- It only resolves if all promises succeed.
- It waits until all promises are rejected.
- It cancels all pending promises immediately.
Understanding Promisify
What does 'promisify' do with a traditional callback-based function?
- It converts the function so that it returns a promise.
- It makes the function run synchronously.
- It merges multiple callbacks into one.
- It delays the function execution by a set time.
- It runs the callback twice for reliability.
Purpose of Throttle
When would you use a 'throttle' function in user interface code?
- To limit how often a function like window resize is called, even if the event fires rapidly.
- To double the number of function executions.
- To trigger a function only after an event has stopped completely.
- To ignore the first event and only handle later ones.
- To randomly delay function execution by a few milliseconds.
Lazy Man Implementation
In a 'Lazy Man' design, which behavior does the object typically exhibit?
- It chains together asynchronous actions so they execute in a specific order.
- It processes all actions in parallel immediately.
- It ignores all chained actions except the first.
- It cancels any previously scheduled actions.
- It randomly decides which actions to perform next.