Created
April 13, 2022 22:11
-
-
Save loicnestler/2de284fec063fbdb042f31dbe9655e02 to your computer and use it in GitHub Desktop.
Recursively print all keys of an object
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
const render = (obj, prefix = '') => { | |
Object.keys(obj).forEach((key, index) => { | |
if(obj[key]?.constructor === Object) return render(obj[key], `${prefix}${key}.`) | |
console.log(`${prefix}${key} ("${obj[key]}")`) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment