InterviewSolution
Saved Bookmarks
| 1. |
Explain async await in JavaScript? |
|
Answer» In Promises we handle any error or REJECT in the .catch block. LET’s look at the below example, where we are sending reject() from cleanroom(). So, now the error will be CAUGHT by the .catch block and then we are displaying the same in console log.
Now, when we refactor the above code using async-await, we don’t have any .catch block. So, we take help from the good old try…catch block AVAILABLE in JAVASCRIPT. |
|