Asynchronous JavaScript Quiz MCQs

Asynchronous JavaScript Quiz

1. What will be the output of the following code?


            setTimeout(() => {
                console.log('Hello');
            }, 2000);
            

2. Which method is used to handle the resolved value of a Promise?

3. What is returned by an async function in JavaScript?

4. What will be the output of this code?


            async function greet() {
                await new Promise(resolve => setTimeout(resolve, 1000));
                console.log('Hello');
            }
            greet();
            

5. Which method is used to handle errors in a Promise?

6. Why is async/await often preferred over using plain Promises?

7. How can errors in async/await code be handled?

8. Which Promise method executes after both resolve and reject cases?

9. What is the purpose of 'resolve' in a Promise constructor function?

10. Where can the 'await' keyword be used?

11. What is a callback function in JavaScript?

12. When is the 'then' method of a Promise called?

13. What does the 'async' keyword do in front of a function?

14. What does 'Promise.all()' do?

15. What does 'Promise.race()' do?

16. When does the 'finally' method of a Promise execute?

17. What is a benefit of using 'async/await' in JavaScript?

18. What does 'Promise.reject()' do?

19. How can you handle errors in an 'async/await' function?

20. What does the 'await' keyword do?

Post a Comment

Your comment will be visible after approval.
© TechTestLog. All rights reserved. Premium By Raushan Design
//My script