DEV Community

Samrat
Samrat

Posted on • Updated on

Higher Order function and Callback function in Javascript?

Callback function : A function passes as argument into another function is called callback function.
Higher order function : A function which receives a callback function is called higher order function.
Example :

function foo(){
    console.log("Hello World");
}
function abu(e){
    e();
}
abu(foo);
Enter fullscreen mode Exit fullscreen mode

In this example abu() and foo() are higher order function and callback function respectively.

Top comments (2)

Collapse
 
szabgab profile image
Gabor Szabo • Edited

Welcome to DEV. You could add syntax highlighting to your code by adding the language after the first triple backticks:

Image description

will result in this:

function foo(){
    console.log("Hello World");
}
function abu(e){
    e();
}
abu(foo);
Enter fullscreen mode Exit fullscreen mode
Collapse
 
samrat9xm profile image
Samrat

Wow!! Nice idea. Thanks for sharing 🥰