JavaScript Async/Await Deep Understanding Quiz
Answer 40 questions on async/await internals: how async functions work, await behavior, try/catch error handling, sequential vs parallel flows, awaiting multiple promises, mixing with raw promises, event loop interaction, return values, pitfalls, and best practices.
Question 1
What does an async function always return?
Question 2
What does await do to the surrounding async function?
Question 3
How are errors handled inside async functions by default?
Question 4
Why is try/catch commonly used with await?
Question 5
What does this async function log?
async function greet() {
return 'hi'
}
greet().then(console.log)Question 6
What happens if you await a non-promise value?
Question 7
How does async/await improve readability over raw promise chains?
Question 8
What do async functions return when there’s no explicit return statement?
Question 9
How does the event loop treat await?
Question 10
Why should async functions avoid returning unhandled rejected promises?
Question 11
What order is logged?
async function run() {
console.log('start')
await Promise.resolve()
console.log('after await')
}
run()
console.log('outside')Question 12
What prints?
async function add() {
const a = await Promise.resolve(2)
const b = await Promise.resolve(3)
return a + b
}
add().then(console.log)Question 13
How can you run two awaits in parallel?
async function fetchBoth() {
const aPromise = fetch('/a')
const bPromise = fetch('/b')
const [a, b] = await Promise.all([aPromise, bPromise])
return [a, b]
}Question 14
What issue exists here?
async function load() {
const user = await fetch('/user')
const posts = await fetch('/posts?user=' + user.id)
return { user, posts }
}Question 15
What does the error handling do?
async function readJson(url) {
try {
const res = await fetch(url)
return await res.json()
} catch (err) {
console.error('Failed', err)
throw err
}
}Question 16
What is logged?
async function chain() {
return await Promise.resolve('value')
}
chain().then(console.log)Question 17
What does this illustrate?
async function example() {
await Promise.reject('oops')
console.log('after reject')
}
example().catch(err => console.log('caught', err))Question 18
What race condition can happen here?
let ready = false
async function setReady() {
await Promise.resolve()
ready = true
}
setReady()
console.log(ready)Question 19
What prints from parallel awaits?
async function parallel() {
const [a, b] = await Promise.all([
Promise.resolve('A'),
Promise.resolve('B')
])
console.log(a + b)
}
parallel()Question 20
Why should you avoid awaiting inside Array.prototype.forEach?
async function process(items) {
items.forEach(async item => {
await save(item)
})
}Question 21
How can you combine async/await with Promise.all for efficiency?
Question 22
How do you handle errors when mixing async/await and .then?
Question 23
What problem arises when forgetting await?
Question 24
How can you parallelize operations inside async functions safely?
Question 25
Why might sequential awaits hurt performance?
Question 26
What best practice applies to async error logging?
Question 27
How can async functions return resolved data to non-await callers?
Question 28
What does queueMicrotask have to do with async/await?
Question 29
What is a pitfall of mixing async/await with Array.map?
Question 30
Why should long-running synchronous code still be avoided inside async functions?
Question 31
What is the best way to retry an async operation?
Question 32
How should you handle cleanup when using await?
Question 33
What is an antipattern when returning promises from async functions?
Question 34
How do you ensure sequential order when needed?
Question 35
What does “fire and forget” mean with async functions?
Question 36
Why is top-level await useful in modules?
Question 37
What is a pitfall when awaiting inside map without return?
Question 38
How can you avoid deadlocks when awaiting user input or events?
Question 39
Why should async functions be composable?
Question 40
What best practice ensures async code remains maintainable?
