Skip to content

Instantly share code, notes, and snippets.

@rndme
Created February 23, 2016 08:27
Show Gist options
  • Save rndme/f7242b26df5aeebcfa62 to your computer and use it in GitHub Desktop.
Save rndme/f7242b26df5aeebcfa62 to your computer and use it in GitHub Desktop.
list of path and values of a deep object
function survey(object) {
function scan(ob, p, x) {
var k, v;
for(k in ob) {
if(!ob.hasOwnProperty(k)) continue;
v=ob[k];
if(typeof v === "object" && v && !+v) {
scan(v, p + "." + k, x);
} else {
x.push( p + "." + k + "=" + v );
}
}
return x;
} //end scan
return scan(object, "", []);
} //end survey()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment