1.

What is the meaning of prototype in JavaScript?

Answer»

A special type of enumerable object to which we can attach additional properties is called a prototype. JavaScript is a dynamic language and at any time we can add new properties to an object and can be shared among all the INSTANCES. Hence to add new properties and implement inheritance prototypes are USED.

2. What is a callback function?

A function passed as an argument to another function is called a callback function and this technique ALLOWS a function to call another function. A callback function gets EXECUTED after the execution of another function gets finished.

Example

function myDisplayer(some) {
      document.getElementById("demo").innerHTML = some;
}

function myCalculator(num1, num2, myCallback) {
      let sum = num1 + num2;
      myCallback(sum);
}

myCalculator(5, 5, myDisplayer);



Discussion

No Comment Found