Skip to content

Instantly share code, notes, and snippets.

@Rplus
Created February 23, 2018 08:00
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 Rplus/1689a558dfeaffebf59e53dfdfd123ed to your computer and use it in GitHub Desktop.
Save Rplus/1689a558dfeaffebf59e53dfdfd123ed to your computer and use it in GitHub Desktop.
// getDeepProp({a: {b: 3}}, 'a.b') => 3
export function getDeepProp(obj, deepProp, splitChar = '.') {
return deepProp.split(splitChar).reduce((_obj, _deepProp) => _obj && _obj[_deepProp], obj);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment