Skip to content

Instantly share code, notes, and snippets.

@loicnestler
Created April 13, 2022 22:11
Show Gist options
  • Save loicnestler/2de284fec063fbdb042f31dbe9655e02 to your computer and use it in GitHub Desktop.
Save loicnestler/2de284fec063fbdb042f31dbe9655e02 to your computer and use it in GitHub Desktop.
Recursively print all keys of an object
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