InterviewSolution
| 1. |
Explain Promise.all with async-await? |
|
Answer» Constructor functions are the equivalent of classes of traditional programming languages like C++ and Java. Sometimes people will refer to them as reference types, classes, data types, or simply constructors. If you aren’t familiar with classes, they are a construct that allows you to specify some properties and behaviours (functions), and multiple objects can be created with those properties and behaviours. A common analogy you’ll often hear is, a class is an architecture’s map and an object is a house created using it. Multiple houses can be created from a single map, as multiple objects can be created from a class. Let’s start with creating a simple function using object to create employee objects. Now consider the line var newObj = {} and return newObj. They will be same in every function which we create. So, JavaScript GIVES us a special type of function known as Constructor function to create them. We will refactor the above to USE Constructor function. LOOK at the below code. We are adding the keyword NEW to create the object. It basically takes care of the creation and returning of the newObj. But gives this a new name this. We can also add methods to a Constructor function and then it can be CALLED with any object created with new keyword. |
|