const numbers = [1, 2, 3, 4, 5];
for (let number of numbers) { // prefer-const
if (number === 2) {
continue;
} else if (number == 4) {
return;
}
console.log(number);
}
eslint say
number is never modified, use const instead.(prefer-const)
const numbers = [1, 2, 3, 4, 5];
for (const number of numbers) {
if (number === 2) {
continue;
} else if (number == 4) {
return;
}
console.log(number);
}
RubyMine 7.1.4 say
const variable without initializer. It won't be possible to assign meaningful value later.
What should I do?
(I think const
is ok, remove RubyMine warnings, but how?)
You can use both, it doesn't make much of a difference. Did you plan that it should not be modified? Use const
. Do you consider it might need to be modified? Use let
. Don't you care? Use either, or what your styleguide recommends, in this case const
.
That RubyMine warning is clearly wrong, they should fix the bug.