Created
November 10, 2017 10:55
-
-
Save schorfES/e48b2b73ff5a28e933626adb308da745 to your computer and use it in GitHub Desktop.
Dev tools snippet for searching props in objects
This file contains 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
console.search = console.search || function (obj, key, path = '.') { | |
Object.keys(obj).forEach(function(k) { | |
var o = obj[k]; | |
if (!o) { | |
return; | |
} | |
if (k.toLowerCase() === key.toLowerCase()) { | |
console.log(path + k); | |
} | |
if (typeof o === 'object') { | |
console.search(o, key, path + k + '.'); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment