Skip to content

Instantly share code, notes, and snippets.

@kovalenko-anton
Created May 4, 2019 12:07
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 kovalenko-anton/0da67fb374d270930a1a06cc93408fc3 to your computer and use it in GitHub Desktop.
Save kovalenko-anton/0da67fb374d270930a1a06cc93408fc3 to your computer and use it in GitHub Desktop.
function getNested(obj, deepKey, delimiter = '.') {
let args = deepKey.split(delimiter);
for (let i = 0; i < args.length; i++) {
if (!obj || !obj.hasOwnProperty(args[i])) {
return undefined;
}
obj = obj[args[i]];
}
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment