Created
September 18, 2018 15:29
-
-
Save JohnMarkT/142817d2abfa43da802d5dc79db905da to your computer and use it in GitHub Desktop.
get deeply nested property -- returns undefined if not found
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
function getDeep(obj, key) { | |
return key.split('.').reduce((o, x) => { | |
return (o || {})[x]; | |
}, obj); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment