Skip to content

Instantly share code, notes, and snippets.

@nurbek-ab
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nurbek-ab/7d88aa3e7c5cd5d4c6a6 to your computer and use it in GitHub Desktop.
Save nurbek-ab/7d88aa3e7c5cd5d4c6a6 to your computer and use it in GitHub Desktop.
forEach for NodeList and HTMLCollection
NodeList.prototype.forEach = function(fn){
var list = this;
for(var i = 0; i < list.length; i++){
fn.call(list[i], list[i], i, list);
}
};
HTMLCollection.prototype.forEach = NodeList.prototype.forEach;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment