Skip to content

Instantly share code, notes, and snippets.

@bogdanRada
Created December 14, 2012 13:57
Show Gist options
  • Save bogdanRada/4285628 to your computer and use it in GitHub Desktop.
Save bogdanRada/4285628 to your computer and use it in GitHub Desktop.
Array.prototype.forEach
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