Created
January 3, 2014 17:45
-
-
Save jimkang/8242606 to your computer and use it in GitHub Desktop.
Tacking forEach onto NodeList to reduce annoyance at it being different from [].
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 nodeListEach(callback, thisArg) { | |
for (var i = 0; i < this.length; ++i) { | |
var value = this[i]; | |
if (thisArg) { | |
callback.bind(thisArg)(value, i, this); | |
} | |
else { | |
callback(value, i, this); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment