Skip to content

Instantly share code, notes, and snippets.

@fvdm
Created January 29, 2015 10:39
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 fvdm/3a55652928a8aa38f5b8 to your computer and use it in GitHub Desktop.
Save fvdm/3a55652928a8aa38f5b8 to your computer and use it in GitHub Desktop.
Object.forEach()
// 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