JavaScript From Beginner To Advanced

0% completed

Previous
Next
Quiz
What is a Promise in JavaScript?
A
A callback function used for asynchronous operations
B
A data structure that stores multiple values simultaneously
C
An object representing the eventual completion or failure of an asynchronous operation
D
A method to pause the execution of code until a variable is available
Which of the following is NOT a state of a Promise?
A
Pending
B
Fulfilled
C
Rejected
D
Paused
What is the output of the following code?
Promise.resolve(1)
    .then(x => x + 1)
    .then(x => { throw new Error('My Error') })
    .catch(() => 1)
    .then(x => x + 1)
    .then(x => console.log(x))
    .catch(console.error);
A
1
B
2
C
3
D
"My Error"
How are errors handled in promise chains?
A
By a global error handler that catches all uncaught promise rejections
B
Only at the end of the chain with a single catch statement
C
Through catch handlers that can be placed anywhere in the promise chain
D
Errors in promises cannot be caught and handled

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next