nodelist-foreach-polyfill
Version:
Simple polyfill for the NodeList.forEach method.
32 lines (22 loc) • 889 B
Markdown
Provides a polyfill for [Nodelist.prototype.forEach()](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach) to all Browsers supporting [ES5](https://caniuse.com/#search=es5).
Chrome 51, Firefox 50, Opera 38, Safari 10
Android Browser none, IE Mobile none, IE none
See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach) for more information.
```JavaScript
// CommonJS
require('nodelist-foreach-polyfill');
// ES6 Modules import / Typescript import
import 'nodelist-foreach-polyfill';
```
```JavaScript
// Get Nodelist from DOM via document.querySelectorAll()
var elements = document.querySelectorAll('.foo');
// Loop through nodelist
elements.forEach(function(element, index, nodelist) {
console.log(this, element, index, nodelist);
});
```