DEV Community

Cover image for Higher order Functions
Srivastan
Srivastan

Posted on

Higher order Functions

So I was going through lot of YouTube videos on this topic...wich made me eventually find wtf is this concept ...is ..
In javascript a function is nothing but an value,

Consider
Enter fullscreen mode Exit fullscreen mode
    Function Myrollno(value){
       return  value
            }

   let outputvalue = Myrollno(21)

    So if we 
   console.log(outputvalue)

    Output :
       21
Enter fullscreen mode Exit fullscreen mode

Hmm...so what happens we pass function instead of a value to the function ....that's what Higher order functions are...

Still not clear .. consider
the example below

    var filtered = [12,5,8,130] ;

    functionisAboveMyRange(value){
        return value >= 25;
     }

   filtered.filter(isAboveMyRange);

Enter fullscreen mode Exit fullscreen mode

So 'filter' Function is called as an Higher order function ,the function we pass as Argument is called an callback function...

Still having Doubts comment it

Top comments (0)