InterviewSolution
| 1. |
How do we handle errors in async-await function? |
|
Answer» Let US first consider the below code for NORMAL Constructor function. Here we can directly access the variable “name” by person.name. Now, we implement the same in JavaScript using Closures. We have two closure functions setName and getName which are BASICALLY “setters” and “getters”. Now, the variable _name is private and cannot be accessed outside the function by person._name and we can access it only by person.getName() |
|