Created
December 4, 2012 16:00
-
-
Save chilloutman/4205495 to your computer and use it in GitHub Desktop.
JavaScript: forEach support for older browsers
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
/* | |
* forEach support for older browsers. | |
* Source: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach | |
*/ | |
(function() { | |
"use strict"; | |
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