Skip to content

Instantly share code, notes, and snippets.

@brentlintner
Created January 18, 2011 17:57
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 brentlintner/784839 to your computer and use it in GitHub Desktop.
Save brentlintner/784839 to your computer and use it in GitHub Desktop.
hijack Array.forEach for objects
Object.prototype.forEach = function (callback) {
var obj = this;
Array.prototype.forEach.call(Object.keys(obj), function (prop) {
callback(obj[prop], prop);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment