Created
November 14, 2018 07:58
-
-
Save mfandl/dd6aa19881f4dfdbb66f9b5ac476618d to your computer and use it in GitHub Desktop.
This file contains 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 propertyExtractor = propName => ({ [propName]: prop }) => prop | |
const idExtractor = propertyExtractor('id') | |
const nameExtractor = propertyExtractor('name') | |
const convict = { id: 7556, name: 'ash' } | |
console.log(idExtractor(convict), nameExtractor(convict)) // 7556 "ash" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment