Skip to content

Instantly share code, notes, and snippets.

@SkyronDevelopers
Created June 24, 2013 09:47
Show Gist options
  • Save SkyronDevelopers/5848974 to your computer and use it in GitHub Desktop.
Save SkyronDevelopers/5848974 to your computer and use it in GitHub Desktop.
Shim .forEach => ECMAScript before v5
// 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