Skip to content

Instantly share code, notes, and snippets.

@chilloutman
Created December 4, 2012 16:00
Show Gist options
  • Save chilloutman/4205495 to your computer and use it in GitHub Desktop.
Save chilloutman/4205495 to your computer and use it in GitHub Desktop.
JavaScript: forEach support for older browsers
/*
* forEach support for older browsers.
* Source: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach
*/
(function() {
"use strict";
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(fn, scope) {
for(var i = 0, len = this.length; i < len; ++i) {
fn.call(scope || this, this[i], i, this);
}
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment