TutorialPedia.org
Toggle Menu
Home
Online Go Compiler
Tutorials
JavaScript Tutorials
Golang Tutorials
Linux Command Line Tutorials
Blog
All Posts
JavaScript Asynchronous Programming
Test your knowledge of promises,async/await,and the event loop.
1. Which of the following is NOT a state of a JavaScript Promise?
pending
fulfilled
rejected
resolved
2. Which of the following are asynchronous operations in JavaScript?
setTimeout()
console.log()
fetch()
Synchronous function call
Promise.resolve()
3. The 'await' keyword can only be used inside an async function.
True
False
4. What does the acronym 'API' stand for in the context of web requests?
5. What is the output order of: console.log(1); setTimeout(() => console.log(2), 0); console.log(3);
1, 2, 3
1, 3, 2
3, 1, 2
2, 1, 3
6. Which of the following are classified as microtasks in JavaScript?
Promise.then()
setTimeout()
queueMicrotask()
setImmediate()
MutationObserver
7. An async function always returns a Promise.
True
False
8. Which method is used to explicitly handle a rejected Promise?
.then()
.catch()
.finally()
.resolve()
9. Name the mechanism that manages the execution order of asynchronous code in JavaScript.
10. Which of the following functions return a Promise?
fetch()
setTimeout()
Promise.all()
async function() {}
XMLHttpRequest()
11. What is the result of 'await Promise.resolve(5);'?
5
Promise { 5 }
undefined
Error
12. Microtasks are executed before the next macrotask in the event loop.
True
False
13. What keyword is used to declare an asynchronous function in JavaScript?
14. Which method runs multiple Promises in parallel and resolves only when all have resolved?
Promise.resolve()
Promise.all()
Promise.race()
Promise.allSettled()
15. How can errors be handled in async/await code?
try/catch block
.catch() method
throw statement
finally block
console.error()
16. setTimeout with a delay of 0ms executes immediately after the current line of code.
True
False
17. What is the return value of an async function with no explicit return statement?
undefined
Promise { undefined }
null
Error
18. Which of the following are examples of macrotasks?
setTimeout()
setInterval()
Promise.then()
I/O operations
queueMicrotask()
19. Promise.race() resolves or rejects as soon as any of its input Promises settles.
True
False
20. What does 'AJAX' stand for, a technique for asynchronous web requests?
Reset
Answered 0 of 0 — 0 correct