Last active
August 29, 2015 14:20
-
-
Save alexcorvi/d73d8dac6b58b0383dac to your computer and use it in GitHub Desktop.
multilevel loop through Javascript Object
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
function traverse(obj) { | |
for (var prop in obj) { | |
// do something with obj[prop] | |
if (obj[prop] !== null && typeof(obj[prop])=="object") { | |
//going on step down in the object tree!! | |
traverse(obj[prop]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment