Skip to content

Instantly share code, notes, and snippets.

@fdiasr
Last active September 18, 2018 04:07
Show Gist options
  • Save fdiasr/2f3c9cfc39f57ae4937104d6027275aa to your computer and use it in GitHub Desktop.
Save fdiasr/2f3c9cfc39f57ae4937104d6027275aa to your computer and use it in GitHub Desktop.
Functional Javascript
// Regular function
function myFunction(a, b) {
return a + b
}
// Lambda function
const myLambda = (a, b) => a + b
// First Class type
const handler = () => console.log('this is a function')
document.eventListener('click', handler)
// High order function - Accept functiona s argument and return function as value
// First order function - Not Accept function as argument and does not return function as value
const firstOrder = () => console.log('first order function')
const highOrder = otherFunction => otherFunction()
highOrder(firstOrder)
// Unary function - only one argument
const unaryFunction = argument => console.log(argument)
const binaryFunction = (arg1, arg2) => console.log(`this method contais 2 args: ${arg1}, ${arg2}`)
const ternaryFunction = (arg1, arg2, arg3) => console.log(`this method contais 3 args: ${arg1}, ${arg2}, ${arg3}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment