Created
May 24, 2010 21:28
-
-
Save dshaw/412449 to your computer and use it in GitHub Desktop.
Array.prototype.forEach
This file contains hidden or 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
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/forEach | |
if (!Array.prototype.forEach) | |
{ | |
Array.prototype.forEach = function(fun /*, thisp*/) | |
{ | |
var len = this.length >>> 0; | |
if (typeof fun != "function") | |
throw new TypeError(); | |
var thisp = arguments[1]; | |
for (var i = 0; i < len; i++) | |
{ | |
if (i in this) | |
fun.call(thisp, this[i], i, this); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment