Created
July 27, 2016 15:49
-
-
Save commanda/48b611bd8f4fd1e5708c7ac2aa9d6822 to your computer and use it in GitHub Desktop.
traverse a json-ish structure in 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
function traverse(object, block) | |
{ | |
for(var i in object) | |
{ | |
block(typeof(object[i]) !== "object", i, object[i]); | |
if(object[i] !== null && typeof(object[i]) !== "string") | |
{ | |
traverse(object[i], block); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment