Skip to content

Instantly share code, notes, and snippets.

@paradigm314
Created May 17, 2017 16:07
Show Gist options
  • Save paradigm314/4f16734285efb4a7fd426426c87cb22b to your computer and use it in GitHub Desktop.
Save paradigm314/4f16734285efb4a7fd426426c87cb22b to your computer and use it in GitHub Desktop.
Traces a JS object recursively following an array path of keys.
function objectPropertyTrace(object, path){
let key = path.shift();
let o = object[key];
if(path.length === 0 || o === undefined || path[0] === ""){
return o;
} else {
return objectPropertyTrace(o, path);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment