Created
August 25, 2016 19:20
-
-
Save asduser/3a0ef85b0d60cc116560560f460d92c6 to your computer and use it in GitHub Desktop.
A way to modify an internal function checking.
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
// | |
// ES5 IMPLEMENTATION | |
// | |
function applyFilter(binary){ | |
return function(a,b){ | |
return binary(a,b); | |
} | |
} | |
function add(a,b){ return a + b; } | |
function mult(a,b){ return a * b } | |
// Examples: | |
applyFilter(add)(5,1) // -> 6 | |
applyFilter(mult)(5,1) // -> 5 |
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
// | |
// ES6 IMPLEMENTATION | |
// | |
const applyFilter = (binary) => { | |
return (a,b) => { | |
return binary(a,b); | |
} | |
} | |
const add = (a,b) => { return a + b; } | |
const mult = (a,b) => { return a * b; } | |
// Examples: | |
applyFilter(add)(5,1) // -> 6 | |
applyFilter(mult)(5,1) // -> 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment