Last active
September 18, 2018 04:07
-
-
Save fdiasr/2f3c9cfc39f57ae4937104d6027275aa to your computer and use it in GitHub Desktop.
Functional Javascript
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
// 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