Skip to content

Instantly share code, notes, and snippets.

@janbaer
Last active December 17, 2015 19:29
Show Gist options
  • Save janbaer/5660471 to your computer and use it in GitHub Desktop.
Save janbaer/5660471 to your computer and use it in GitHub Desktop.
Polyfill for missing forEach function an an Array object in JavaScript
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(fn, scope) {
for (var i = 0, len = this.length; i < len; ++i) {
fn.call(scope, this[i], i, this);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment