Skip to content

Instantly share code, notes, and snippets.

@dshaw
Created April 29, 2010 17:11
Show Gist options
  • Save dshaw/383902 to your computer and use it in GitHub Desktop.
Save dshaw/383902 to your computer and use it in GitHub Desktop.
jQuery-like each implementation
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