Asynchronous JavaScript is key to handling time-consuming tasks like API calls, timers, and user interactions without blocking the main thread. Topics like promises, async/await, callbacks, and methods such as fetch() are crucial for modern web development. Understanding these concepts helps write efficient, non-blocking code that is often tested in interviews. Practicing MCQs on these topics is an excellent way to prepare and boost interview confidence.
1.) What is asynchronous JavaScript?
A) Code executed line by line in order
B) Code executed in parallel without blocking
C) Code executed only after page load
D) Code executed without using variables
2.) Which method is used to handle promises in JavaScript?
A) catch
B) then
C) finally
D) All of the above
3.) What does setTimeout() do in JavaScript?
A) Executes a function immediately
B) Executes a function after a delay
C) Stops code execution for a set time
D) Executes code repeatedly
4.) What is the purpose of async in JavaScript?
A) Makes a function asynchronous
B) Converts a promise into a callback
C) Pauses function execution
D) Returns multiple promises
5.) What does await do in an async function?
A) Creates a promise
B) Resolves a promise
C) Pauses the execution until the promise resolves
D) Rejects a promise
6.) Which function repeatedly executes code after a set interval?
A) setTimeout()
B) setInterval()
C) setRepeater()
D) executeLater()
7.) What happens if await is used outside an async function?
A) It works normally
B) It throws an error
C) It resolves the promise automatically
D) It skips the await keyword
8.) What is the default state of a JavaScript promise?
A) Resolved
B) Rejected
C) Pending
D) Fulfilled
9.) How do you create a new promise?
A) new Promise()
B) Promise.create()
C) Promise.start()
D) new Async()
10.) What is the purpose of Promise.all()?
A) Resolves multiple promises sequentially
B) Resolves multiple promises concurrently
C) Rejects all promises if one fails
D) Creates a single promise
Related