Skip to content

Instantly share code, notes, and snippets.

@alexcorvi
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcorvi/d73d8dac6b58b0383dac to your computer and use it in GitHub Desktop.
Save alexcorvi/d73d8dac6b58b0383dac to your computer and use it in GitHub Desktop.
multilevel loop through Javascript Object
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