Skip to content

Instantly share code, notes, and snippets.

@zenius
Created May 3, 2019 12:50
Show Gist options
  • Save zenius/d5e7660406baefadfed8912ef1e3f9dc to your computer and use it in GitHub Desktop.
Save zenius/d5e7660406baefadfed8912ef1e3f9dc to your computer and use it in GitHub Desktop.
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