Last active
August 29, 2015 14:14
-
-
Save jakelazaroff/4aea26991d776091e727 to your computer and use it in GitHub Desktop.
Returns the value of a nested property if it exists, or undefined if it doesn't.
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
function nested(entity, path) { | |
path.split('.').some(function (property) { | |
entity = entity[property]; | |
return typeof entity === 'undefined'; | |
}); | |
return entity; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment