Skip to content

Instantly share code, notes, and snippets.

@jakelazaroff
Last active August 29, 2015 14:14
Show Gist options
  • Save jakelazaroff/4aea26991d776091e727 to your computer and use it in GitHub Desktop.
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.
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