Created
April 11, 2010 17:14
-
-
Save dshaw/362890 to your computer and use it in GitHub Desktop.
Array.prototype.forEach implementation from @Rem
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
// from @rem's dashboard.js: http://rem.im/chirp/dashboard.js | |
if (![].forEach) { | |
Array.prototype.forEach = function(fn) { | |
var len = this.length || 0, | |
i = 0; | |
context = arguments[1]; | |
if (typeof fn == 'function') { | |
for (; i < len; i++) { | |
fn.call(context, this[i], i, this); | |
} | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment