0
0
Javascriptprogramming~5 mins

Why promises are used in Javascript - Quick Recap

Choose your learning style9 modes available
Recall & Review
beginner
What problem do promises solve in JavaScript?
Promises help manage asynchronous operations by avoiding callback hell and making code easier to read and maintain.
Click to reveal answer
beginner
How do promises improve code readability?
Promises allow chaining with .then() and .catch(), which makes asynchronous code look more like synchronous code.
Click to reveal answer
beginner
What are the three states of a promise?
A promise can be pending (waiting), fulfilled (success), or rejected (error).
Click to reveal answer
beginner
Why is callback hell a problem?
Callback hell happens when callbacks are nested deeply, making code hard to read, debug, and maintain.
Click to reveal answer
beginner
How do promises handle errors better than callbacks?
Promises use .catch() to handle errors in one place, avoiding scattered error handling in nested callbacks.
Click to reveal answer
What does a promise represent in JavaScript?
AA value that may be available now, later, or never
BA synchronous function
CA type of variable
DA way to declare constants
Which method is used to handle a successful promise result?
A.resolve()
B.catch()
C.finally()
D.then()
What state is a promise in before it is fulfilled or rejected?
AResolved
BPending
CRejected
DCompleted
How do promises help avoid callback hell?
ABy chaining asynchronous operations cleanly
BBy nesting callbacks deeper
CBy ignoring errors
DBy using synchronous code
Which method is used to catch errors in promises?
A.then()
B.finally()
C.catch()
D.error()
Explain why promises are used in JavaScript and how they improve asynchronous code.
Think about how promises make waiting for data easier and cleaner.
You got /4 concepts.
    Describe the three states of a promise and what each means.
    Consider what happens from start to finish of a promise.
    You got /3 concepts.