Created
April 29, 2018 17:37
-
-
Save eldoy/d38a42a10874f6ff92478048d614b93b to your computer and use it in GitHub Desktop.
Traverse object graph pure vanilla javascript
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
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