-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initilization of a var to 'undefined' in a loop gives wrong error #1191
Comments
hmm, there's nothing like a However, I think you're right - personally, I try to avoid As a workaround, you can use var a;
for (var i=0; i<10; i++)
{
a = undefined;
if (i%2)
a = 1;
if (a===undefined)
console.log("error");
} Greetings, Wolfgang |
(Interesting choice to close #1142 for this issue, but whatever :) I think my main beef was that the error was non-ignorable, but I'm not sure about that at this point. ) |
Whee, this is an old issue. Just came here to chime in about #1142. I ran into a bug in my code where the right answer was to change |
@stevage there you go, I made a PR to fix it. I can also confirm that disabling W080 e.g. |
Whoa, thank you! :) |
👍 |
test.js: line 3, col 9, It's not necessary to initialize 'a' to 'undefined'.
It is necessary, since 'a' is not in the 'for' block scope.
The text was updated successfully, but these errors were encountered: