Skip to content

Instantly share code, notes, and snippets.

@GengGao
Created March 3, 2013 09:08
Show Gist options
  • Save GengGao/5075402 to your computer and use it in GitHub Desktop.
Save GengGao/5075402 to your computer and use it in GitHub Desktop.
MDN .forEach()
// Shim .forEach()
if ( !Array.prototype.forEach ) {
Array.prototype.forEach = function(fn, scope) {
for (var i = 0, len = this.length; i < len; ++i) {
fn.call(scope || this, this[i], i, this);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment