Skip to content

Instantly share code, notes, and snippets.

@ianpgall
Last active December 20, 2015 15:59
Show Gist options
  • Save ianpgall/6158503 to your computer and use it in GitHub Desktop.
Save ianpgall/6158503 to your computer and use it in GitHub Desktop.
JavaScript function that allows the deep navigation of an Object, invoking a callback upon every single property
var Navigate = (function () {
"use strict";
var O, func;
O = {};
func = function (obj, callback) {
var iterator = function (o) {
var k, cur;
for (k in o) {
cur = o[k];
if (O.toString.call(cur) === "[object Object]") {
iterator(cur);
} else {
callback(k, cur, o);
}
}
};
iterator(obj);
};
return func;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment