I have this code:
data.forEach(item => {
for (const i in Object.keys(item)) {
const key = Object.keys(item)[i];
//..
}
});
eslint throwing an error:
error The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype guard-for-in
I did research and tried to fix that this way:
data.forEach(item => {
if (pattern.hasOwnProperty(i)) {
for (const i in Object.keys(item)) {
const key = Object.keys(item)[i];
//..
}
}
});
So that made the linter happy but the for..in
loop now does not work.
that is the value of the item
- { 'bla': '42' }
Any ideas how to solve?