Last active
August 29, 2015 14:10
-
-
Save nurbek-ab/7d88aa3e7c5cd5d4c6a6 to your computer and use it in GitHub Desktop.
forEach for NodeList and HTMLCollection
This file contains 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
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