I am using ESLint in my project and am using the airbnb style guide. The following piece of code in my program is giving me a linting issue. I am working on ES6. It's telling me to avoid using for-in here. What would be a better alternative as per ES6 standards ?
function solveRole (i18nData) {
entries = {};
for (const property in i18nData) {
entries[property] = i18nData[property];
}
}
There's no need to iterate over the keys using either a for-in
loop or Object.keys(...).forEach
as all you are doing is assigning all properties of one object to another.
Try this:
const entries = Object.assign({}, i18nData)
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