Last active
August 13, 2021 13:32
-
-
Save arpruss/8efd70269e5562bda54a33524beec67d to your computer and use it in GitHub Desktop.
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 finder(obj, keyToFind, level=7, soFar='', searched=new Set) { | |
if (level<=0 || typeof obj != 'object' || obj === null || searched.has(obj)) return; | |
searched.add(obj) | |
if (keyToFind in obj) { | |
console.log(soFar + '.' + keyToFind) | |
} | |
for (let key in obj) { | |
try { | |
finder(obj[key], keyToFind, level-1, soFar + '.' + key, searched); | |
} | |
catch(e) {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment