Created
January 29, 2015 10:39
-
-
Save fvdm/3a55652928a8aa38f5b8 to your computer and use it in GitHub Desktop.
Object.forEach()
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.forEach( function( value, key, index ) {} ) | |
Object.prototype.forEach = function( cb ) { | |
var keys = Object.keys(this); | |
for( var i = 0; i < keys.length; i++ ) { | |
var key = keys[i]; | |
cb( this[key], key, i ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment