Created
February 23, 2018 08:00
-
-
Save Rplus/1689a558dfeaffebf59e53dfdfd123ed to your computer and use it in GitHub Desktop.
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
// 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