Skip to content

Instantly share code, notes, and snippets.

@Rplus
Created Feb 23, 2018
Embed
What would you like to do?
// 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