Created
January 18, 2011 17:57
-
-
Save brentlintner/784839 to your computer and use it in GitHub Desktop.
hijack Array.forEach for objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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