Created
May 17, 2017 16:07
-
-
Save paradigm314/4f16734285efb4a7fd426426c87cb22b to your computer and use it in GitHub Desktop.
Traces a JS object recursively following an array path of keys.
This file contains hidden or 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
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