I have below snippet
data.forEach(function (row) {
var dataRow = [];
columns.forEach(function (column) {
dataRow.push(row[column].toString());
})
which is giving me error data.forEach(function (row) {
.What should be alternate to this? How to resolve it?
For anyone using document.querySelectorAll('..').forEach() and having this issue in IE 11 saying "forEach is not a function", I found a hack on reddit which worked nicely:
if (typeof NodeList.prototype.forEach !== 'function') {
NodeList.prototype.forEach = Array.prototype.forEach;
}
This works perfectly and is 3 lines of code instead of a polyfill.
@JoeTaras hinted at this in his answer (yes IE does have Array.forEach since IE9), but I still think my answer adds value and will help other users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With