Sometimes, we want to avoid no-param-reassign ESLint error when setting a property on a DOM object with JavaScript.
In thiks article, we’ll look at how to avoid no-param-reassign ESLint error when setting a property on a DOM object with JavaScript.
How to avoid no-param-reassign ESLint error when setting a property on a DOM object with JavaScript?
To avoid no-param-reassign ESLint error when setting a property on a DOM object with JavaScript, we can assign the parameter to a variable.
For instance, we write
const f = (el) => {
const theElement = el;
theElement.expand = {};
};
to create the f function.
In it, we assign el to the theElement variable.
And then we add the theElement.expand property to it.
Conclusion
To avoid no-param-reassign ESLint error when setting a property on a DOM object with JavaScript, we can assign the parameter to a variable.