Skip to content

Instantly share code, notes, and snippets.

@Cojad
Last active September 7, 2016 08:55
Show Gist options
  • Save Cojad/fc946748f9efdb419827707507459ba2 to your computer and use it in GitHub Desktop.
Save Cojad/fc946748f9efdb419827707507459ba2 to your computer and use it in GitHub Desktop.
list hierarchy javascript object values
child = function(obj,name){
for( var index in obj){
switch(typeof obj[index]) {
case "object": child(obj[index],name+"."+index);break;
case "string": console.log(name+"."+index+" = \"" + obj[index] + "\"");break;
case "number": console.log(name+"."+index+" = " + obj[index]);break;
case "boolean": console.log(name+"."+index+" = \""+ (obj[index]) ? "true":"false" + "\"");break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment