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, this might be not desirable at many places and in Traditional languages like C++ and JAVA, this is  solved by the having “private” variables in class and then having “Getters” and “SETTERS” to access them. 

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() 



Discussion

No Comment Found