Skip to content

Instantly share code, notes, and snippets.

@seogi1004
Created November 27, 2017 13:50
Show Gist options
  • Save seogi1004/18529e3760ffb6ee7570e7c2aa03516d to your computer and use it in GitHub Desktop.
Save seogi1004/18529e3760ffb6ee7570e7c2aa03516d to your computer and use it in GitHub Desktop.
Array.prototype.each = function(callback) {
for(i = 0; i < this.length; i++) {
callback.prototype = this[i];
new callback(i);
}
};
var test = [ { name : 'a' }, { name : 'b' }, { name : 'c' } ];
test.each(function(index) {
alert(index + " = " + this.name);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment