Created
December 14, 2012 13:57
-
-
Save bogdanRada/4285628 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
if (!Array.prototype.forEach) | |
{ | |
Array.prototype.forEach = function(fun /*, thisp*/) | |
{ | |
var len = this.length; | |
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