Skip to content

Instantly share code, notes, and snippets.

@jremmen
Created June 8, 2013 21:41
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 jremmen/5736714 to your computer and use it in GitHub Desktop.
Save jremmen/5736714 to your computer and use it in GitHub Desktop.
js: recursive object enumerator
function enumObj(obj) {
function recur(obj, acc) {
for(var prop in obj) {
if(obj[prop] instanceof Object && typeof obj[prop] === 'object') {
acc.push(recur(obj[prop], []));
} else {
acc.push(prop + ':' + obj[prop]);
}
}
return acc;
}
return recur(obj, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment