11.) What is the purpose of Promise.race()?
A) Resolves with the fastest promise
B) Resolves with all promises’ results
C) Rejects all promises if one fails
D) Pauses until all promises are complete
12.) What does the fetch() method do?
A) Sends HTTP requests and returns a promise
B) Creates DOM elements
C) Executes functions asynchronously
D) Fetches variables from memory
13.) How do you ensure a function runs only after a specific promise is resolved?
A) Use setTimeout.
B) Use .then() or await.
C) Use Promise.reject.
D) Use a synchronous loop.
14.) How do you handle errors in an async function?
A) Using catch
B) Using try…catch
C) Using finally
D) None of the above
15.) Which of these is NOT asynchronous in JavaScript?
A) setTimeout()
B) fetch()
C) Promise.all()
D) for loop
16.) What does Promise.resolve() do?
A) Resolves a pending promise with a given value
B) Rejects a promise
C) Creates a pending promise
D) Waits for a promise to resolve
17.) How do you cancel an interval set with setInterval()?
A) stopInterval()
B) clearTimeout()
C) clearInterval()
D) cancelInterval()
18.) Which is NOT true about Promise.finally()?
A) It executes after the promise is settled.
B) It does not modify the resolved value.
C) It runs only on a rejected promise.
D) It can be used for cleanup.
19.) What is the main drawback of callbacks?
A) Callback hell (nested callbacks)
B) Poor readability
C) Difficult error handling
D) All of the above
20.) How do you convert a callback-based function into a promise?
A) Using async
B) Using Promise.race()
C) Using the Promise constructor
D) Using await
Related