Created
August 9, 2012 11:42
-
-
Save zziuni/3303495 to your computer and use it in GitHub Desktop.
Array.forEach and NodeList.forEach Compatibility
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
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