Skip to content

Instantly share code, notes, and snippets.

@L3V147H4N
Created March 10, 2016 14:49
Show Gist options
  • Save L3V147H4N/edcbb8659c2540c421fc to your computer and use it in GitHub Desktop.
Save L3V147H4N/edcbb8659c2540c421fc to your computer and use it in GitHub Desktop.
Javascript find Deep Value
function deepFind (path, obj) {
var
paths = path.split('.'),
current = obj || this;
for (var i = 0; i < paths.length; ++i) {
if (current[paths[i]] == undefined) {
return undefined;
} else {
current = current[paths[i]];
}
}
return current;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment