I typically follow Airbnb's ESLint configuration and I noticed I was getting throwing errors for using For...In loops? Why is this the case?
I've read into it a bit Here, but I would like a more detailed explanation or example.
const data = {
color : 'blue',
movies : 'action',
hobby : 'football',
};
for (let prop in data) {
console.log(`prop: ${prop} and value is ${data[prop]}`);
}
//Throws Guarding for in, should be wrapped in an if statement to
//filter unwated properties from the prototype.
Object.keys(data).forEach((element) => {
console.log(`prop: ${element} and value is ${data[element]}`);
});
//This is Okay