Skip to content Skip to sidebar Skip to footer

ESLint Says Array Never Modified Even Though Elements Are Pushed Into Array

I am converting some existing code to follow ECMA script and I am using ESLint to follow a coding standard. I have the following ecmascript method static getArrayOfIndices(text, c

Solution 1:

To understand this error you must understand that const declared variables hold read-only references to a value. But it does not mean that the value it holds is immutable [mdn article].

Since you are only changing members of the variable, but not performing a reassignment on the binding the prefer-const rule of es-lint warns you that a const declared variable could be used instead of a let declared variable.


Post a Comment for "ESLint Says Array Never Modified Even Though Elements Are Pushed Into Array"