Skip to content

Instantly share code, notes, and snippets.

@danieldai
Last active November 26, 2021 08:15
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 danieldai/8729e6536031275b10f09cc699e6c494 to your computer and use it in GitHub Desktop.
Save danieldai/8729e6536031275b10f09cc699e6c494 to your computer and use it in GitHub Desktop.
get_next_property.js
function getNestedProperty(obj, path) {
let myObj = obj;
for (let name of path.split('.')) {
if (myObj) {
myObj = myObj[name];
} else {
break;
}
}
return myObj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment