Skip to content

Instantly share code, notes, and snippets.

@zziuni
Created August 9, 2012 11:42
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 zziuni/3303495 to your computer and use it in GitHub Desktop.
Save zziuni/3303495 to your computer and use it in GitHub Desktop.
Array.forEach and NodeList.forEach Compatibility
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);
}
}
}
if ( !NodeList.prototype.forEach ) {
NodeList.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