Skip to content

Instantly share code, notes, and snippets.

@sAbakumoff
Created October 7, 2016 13:53
Show Gist options
  • Save sAbakumoff/74358cca0e1647a0a8a4ac59111fb6be to your computer and use it in GitHub Desktop.
Save sAbakumoff/74358cca0e1647a0a8a4ac59111fb6be to your computer and use it in GitHub Desktop.
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback, thisArg) {
if (this === null) {
throw new TypeError('Array.prototype.forEach called on null or undefined');
}
if (typeof callback !== "function") {
throw new TypeError(callback + ' is not a function');
}
var O = Object(this), len = O.length >>> 0, k = 0, value;
if (arguments.length > 1) {
value = thisArg;
}
while (k < len) {
if (k in O) {
callback.call(value, O[k], k, O);
}
k++;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment