Created
May 13, 2020 17:50
-
-
Save marekdano/4c368c8a0069f7a8905f5b0a64d43c73 to your computer and use it in GitHub Desktop.
Partial Application
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
const multiply = (a, b) => a * b | |
function prefillFunction (fn, prefilledValue) { | |
const inner = liveInput => { | |
const output = fn(liveInput, prefilledValue) | |
return output | |
} | |
return inner | |
} | |
const multiplyBy2 = prefillFunction(multiply, 2) | |
const result = multiplyBy2(5) | |
console.log(result) // 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment