Skip to content

Instantly share code, notes, and snippets.

@jbonhag
Created February 15, 2016 19:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbonhag/dee25133a245110ee354 to your computer and use it in GitHub Desktop.
Save jbonhag/dee25133a245110ee354 to your computer and use it in GitHub Desktop.
Add map function to HTMLCollection
HTMLCollection.prototype.map = function(f) {
var result = [];
for (var i = 0; i < this.length; i = i + 1) {
el = elements[i];
result.push(f(el));
};
return result;
}
@deancasalena
Copy link

-     el = elements[i];
+     el = this[i];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment