Skip to content

Instantly share code, notes, and snippets.

@roberto
Last active January 24, 2018 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roberto/7eebf200fde8ae9b8a6754e0260eca36 to your computer and use it in GitHub Desktop.
Save roberto/7eebf200fde8ae9b8a6754e0260eca36 to your computer and use it in GitHub Desktop.
Currying - Simple
const myProp = (key, maybeObject) => {
if (maybeObject === undefined) {
return (object) => {
return myProp(key, object)
}
}
return maybeObject[key]
}
const myProp = (key, maybeObject) =>
maybeObject === undefined
? (object) => myProp(key, object)
: maybeObject[key]
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