Skip to content

Instantly share code, notes, and snippets.

@mokargas
Last active February 22, 2017 00:52
Show Gist options
  • Save mokargas/92941cce737ee0549e7f4e7dbb347c18 to your computer and use it in GitHub Desktop.
Save mokargas/92941cce737ee0549e7f4e7dbb347c18 to your computer and use it in GitHub Desktop.
What are Higher Order Functions? (JS)

Simple definitions for HoF's:

Major Concepts:

  • A function that will take at least one function as an argument (Primary concept)
  • Does not mutate any state
  • Can return a function (?? Wikipedia)

Examples:

const friends = [  
  { name: 'John', species: 'human', inventory: 'coffee' },  
  { name: 'Steve', species: 'megatoad', inventory: 'coffee' },  
  { name: 'Xerses', species: 'alien', inventory: 'brain juice' },  
]  
let bestFriends = friends.filter( (friend) => { return friend.inventory === 'coffee' });  
console.log(bestFriends)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment