Function - Callback function

1 - About

A callback function is called back by the higher-order function that takes it as parameter.

Callbacks is a method of enabling asynchrony (asynchronous operation).

A callback is a function that is passed as an argument to another function and is executed after its parent function has completed.

As a callback is a function/interface that tend to have only one method, they are generally functional interface.

A callback function is generally used as event handler to respond to an event.

3 - Example

Basic example in Javascript.


callback = function () {
   console.log("Hello Callback");
}

function highOrder(callbackFunctionToCall){
  // Call the callback function
  callbackFunctionToCall();
}

highOrder(callback);

4 - Hell

The callback hell is when there is so much callback that it build a multiple levels of nested callbacks rendering the code difficult to understand.


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap