Created
December 28, 2019 03:11
-
-
Save bhaveshdaswani93/0308163d540c605ea92102f696157d78 to your computer and use it in GitHub Desktop.
In this example i will explain high order function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hocFn = function() { | |
return function() { | |
return 5; | |
} | |
} | |
hocFn() // will return function | |
hocFn()() // will return 5 | |
// hocFn return function so it is HOC | |
const fn = function(x) { | |
return x*2; | |
} | |
const hocFn2 = function(fn) { | |
return fn(5); | |
} | |
hocFn2(fn); // will return 10 | |
// hocFn2 accept function as argument it is an HOC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment