Last active
January 24, 2018 22:55
-
-
Save roberto/7eebf200fde8ae9b8a6754e0260eca36 to your computer and use it in GitHub Desktop.
Currying - Simple
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 myProp = (key, maybeObject) => { | |
if (maybeObject === undefined) { | |
return (object) => { | |
return myProp(key, object) | |
} | |
} | |
return maybeObject[key] | |
} |
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 myProp = (key, maybeObject) => | |
maybeObject === undefined | |
? (object) => myProp(key, object) | |
: maybeObject[key] |
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 myProp = curry((key, obj) => obj[key]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment