Created
April 20, 2016 18:12
-
-
Save TheNeuralBit/4f2c7705ccb818a2b8c32e7095f5bca4 to your computer and use it in GitHub Desktop.
Convenience function for iterating through keys and values of a JS Object
This file contains hidden or 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
// obj.forEach(function(k, v) { ... }); | |
Object.prototype.forEach = function forEach(callback) { | |
for (var key in this) { | |
if (this.hasOwnProperty(key)) { | |
callback(key, this[key]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment