Asynchronous Javascript
Quiz
•
Professional Development
•
University
•
Medium
tiya reba
Used 8+ times
FREE Resource
Enhance your content
9 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a callback function in JavaScript?
A function that is called immediately after it is defined.
A function that returns a promise.
A function passed as an argument to another function to be executed later.
A function that is executed before the main function.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is true about JavaScript promises?
They are used to handle synchronous operations only.
They represent the completion or failure of asynchronous operations.
They are only used with setTimeout.
Promises cannot be chained.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In which JavaScript version were promises introduced?
ES5
ES6
ES7
ES8
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What are the possible states of a JavaScript promise?
Started, Pending, Completed
Resolved, Completed, Failed
Pending, Fulfilled, Rejected
Waiting, Running, Finished
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the async keyword do when used with a function in JavaScript?
Makes the function run immediately.
Allows the function to run as a generator.
Allows the function to handle asynchronous code with await.
Automatically makes the function return null.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a correct example of using await?
const data = await fetch("https://api.example.com");
await const data = fetch("https://api.example.com");
const data = fetch("https://api.example.com").await;
await fetch("https://api.example.com").then(data => console.log(data));
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a correct way to handle an error in an async function?
Use try...catch inside the function.
Use .catch() directly after await.
Errors cannot be handled in an async function.
Use setTimeout to catch errors.
8.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does Promise.resolve() do?
Creates a promise that is automatically rejected.
Pauses the code until a condition is met.
Creates a promise that is already resolved with the specified value.
Returns the status of a promise.
9.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will the following code output to the console?
function makePizza() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve("Pizza is ready");
}, 1000);
});
}
function makeSalad() {
return new Promise((resolve) => {
setTimeout(() => {
resolve("Salad is ready");
}, 500);
});
}
async function prepareDinner() {
const pizza = await makePizza();
const salad = await makeSalad();
console.log(pizza);
console.log(salad);
}
prepareDinner();
"Pizza is ready" followed by "Salad is ready" after 1 second
"Salad is ready" followed by "Pizza is ready" after 1.5 seconds
"Pizza is ready" and "Salad is ready" printed simultaneously after 1 second
"Salad is ready" followed by "Pizza is ready" after 1 second
Similar Resources on Wayground
10 questions
LET Quiz Bee -Elimination Round (Easy)
Quiz
•
University
10 questions
ServSafe Ch. 5 Review Quiz
Quiz
•
10th Grade - Professi...
10 questions
Career Choices
Quiz
•
9th Grade - University
10 questions
Nature of Communication
Quiz
•
University
10 questions
Building Services 2
Quiz
•
University
10 questions
FINANCIAL EDUCATION
Quiz
•
University
11 questions
Economics Production Function Quiz
Quiz
•
University
10 questions
DAY 9 File Handling & Dynamic Memory Allocation - 20th JUNE 24
Quiz
•
University
Popular Resources on Wayground
20 questions
Brand Labels
Quiz
•
5th - 12th Grade
11 questions
NEASC Extended Advisory
Lesson
•
9th - 12th Grade
10 questions
Ice Breaker Trivia: Food from Around the World
Quiz
•
3rd - 12th Grade
10 questions
Boomer ⚡ Zoomer - Holiday Movies
Quiz
•
KG - University
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
Adding Integers
Quiz
•
6th Grade
10 questions
Multiplication and Division Unknowns
Quiz
•
3rd Grade
20 questions
Multiplying and Dividing Integers
Quiz
•
7th Grade
Discover more resources for Professional Development
10 questions
Boomer ⚡ Zoomer - Holiday Movies
Quiz
•
KG - University
22 questions
FYS 2024 Midterm Review
Quiz
•
University
20 questions
Physical or Chemical Change/Phases
Quiz
•
8th Grade - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)
Quiz
•
8th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
12 questions
1 Times Tables
Quiz
•
KG - University
20 questions
Disney Trivia
Quiz
•
University
38 questions
Unit 6 Key Terms
Quiz
•
11th Grade - University