Created
April 29, 2010 17:11
-
-
Save dshaw/383902 to your computer and use it in GitHub Desktop.
jQuery-like each implementation
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
var each = [].forEach || function (fn) { | |
var len = this.length || 0, that = arguments[1]; | |
if (typeof fn == 'function') { | |
for (var i = 0; i < len; i++) { | |
fn.call(that, this[i], i, this); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment