Skip to content

Instantly share code, notes, and snippets.

@webshru
Last active August 3, 2022 14:45
Show Gist options
  • Save webshru/1348f8c7ef56663a91eba235a6f68a2e to your computer and use it in GitHub Desktop.
Save webshru/1348f8c7ef56663a91eba235a6f68a2e to your computer and use it in GitHub Desktop.
Polyfill. Добавление forEach к NodeList (для IE 11)
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this)
}
}
}
// Или
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = Array.prototype.forEach
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment