Skip to content

Instantly share code, notes, and snippets.

@arestov
Created September 17, 2012 09:55
Show Gist options
  • Save arestov/3736506 to your computer and use it in GitHub Desktop.
Save arestov/3736506 to your computer and use it in GitHub Desktop.
iterateObjectDeeply, no recurstion
var iterateObjectDeeply = function(obj, fn) {
var full_tree_array = [obj];
while (full_tree_array.length) {
var cur = full_tree_array.shift();
for (var a in cur){
fn(cur, a);
if (cur[a] && typeof cur[a] == 'object'){
full_tree_array.push(obj[prop_name])
}
}
}
return obj;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment