Skip to content

Instantly share code, notes, and snippets.

@eldoy
Created April 29, 2018 17:37
Show Gist options
  • Save eldoy/d38a42a10874f6ff92478048d614b93b to your computer and use it in GitHub Desktop.
Save eldoy/d38a42a10874f6ff92478048d614b93b to your computer and use it in GitHub Desktop.
Traverse object graph pure vanilla javascript
const traverse = (obj) => {
for (let k in obj) {
if (obj[k] && typeof obj[k] === 'object') {
traverse(obj[k])
} else {
// Do something with obj[k]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment