JavaScript Promises & Promise Chaining Quiz
Tackle 40 questions about JavaScript Promises: states, creating promises, then/catch/finally, value chaining, error propagation, avoiding callback hell, Promise.all, Promise.race, and coordinating multiple async operations.
Question 1
What is a Promise in JavaScript?
Question 2
Which are the three fundamental Promise states?
Question 3
What happens after a Promise settles?
Question 4
Why were Promises introduced?
Question 5
Which two methods register fulfillment and rejection handlers?
Question 6
What does finally do in Promise chains?
Question 7
How does Promise chaining help avoid callback hell?
Question 8
What is a benefit of returning values from a then handler?
Question 9
Why is error propagation simpler with Promises?
Question 10
What does Promise.resolve(value) return?
Question 11
What does this promise log?
const p = new Promise(resolve => {
resolve('done')
})
p.then(value => console.log(value))Question 12
What is printed?
new Promise((resolve, reject) => {
reject(new Error('fail'))
})
.then(() => console.log('won'))
.catch(err => console.log(err.message))Question 13
How many times is finally invoked?
Promise.resolve('ok')
.finally(() => console.log('cleanup'))
.then(value => console.log(value))Question 14
What does the chain output?
Promise.resolve(2)
.then(x => x * 3)
.then(x => Promise.resolve(x + 1))
.then(result => console.log(result))Question 15
What happens to the returned promise?
const p = Promise.resolve('A')
const q = p.then(v => v + 'B')
console.log(p === q)Question 16
What output occurs?
Promise.reject('bad')
.catch(reason => {
console.log('caught', reason)
return 'recovered'
})
.then(value => console.log(value))Question 17
What does this demonstrate?
Promise.resolve()
.then(() => Promise.reject('fail'))
.then(() => console.log('never'))
.catch(err => console.log('caught', err))Question 18
Which value reaches console.log?
Promise.resolve('start')
.then(val => {
console.log(val)
return 'next'
})
.then(console.log)Question 19
What is logged?
const slow = () => new Promise(resolve => setTimeout(() => resolve('S'), 20))
slow()
.then(value => value + '1')
.finally(() => console.log('clean'))
.then(value => console.log(value))Question 20
What does returning a Promise inside then achieve?
Question 21
What is Promise chaining?
Question 22
How do you propagate synchronous errors in a then handler?
Question 23
What happens if you omit catch in a chain?
Question 24
Why is returning inside then important?
Question 25
What is an anti-pattern when mixing Promises and callbacks?
Question 26
How does chaining simplify sequential asynchronous work?
Question 27
Why is catch typically placed near the end of a chain?
Question 28
What is a microtask queue in relation to Promises?
Question 29
What does returning Promise.reject() inside then do?
Question 30
How does Promise chaining compare to nested callbacks for readability?
Question 31
What does Promise.all do?
Question 32
When does Promise.all reject?
Question 33
What does Promise.race return?
Question 34
How can Promise.all be used efficiently?
Question 35
What is logged?
const p1 = new Promise(resolve => setTimeout(() => resolve('A'), 30))
const p2 = Promise.resolve('B')
Promise.all([p1, p2]).then(values => console.log(values.join('-')))Question 36
What happens here?
Promise.race([
new Promise(resolve => setTimeout(() => resolve('slow'), 50)),
Promise.resolve('fast')
]).then(console.log)Question 37
How does Promise.all handle rejection reasons?
Question 38
Why is Promise.allSettled useful?
Question 39
How do Promises handle multiple async operations efficiently?
Question 40
What should you consider when replacing callbacks with Promises?
