Created
May 3, 2019 12:50
-
-
Save zenius/d5e7660406baefadfed8912ef1e3f9dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Functions can be data too !!! | |
Pass them as data like boolean, number, string and Array. | |
const isEven = (num) => num % 2 === 0; // here "function" is assigned to variable "isEven" | |
const result = [1, 2, 3, 4].filter(isEven); // here function "isEven" is passed as an argument. | |
console.log({ result }); // { result: [ 2, 4 ] } | |
***A function that takes and/or returns another function is called a higher-order function. | |
It’s “higher-order” because it operates on functions besides basic data types.*** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment