2 ms·
What is the bug that can result from the "for(var i=0)" pattern? None, beause browsers ignore the second var for the same variable and do te ituitively right th
by Joeri 14y ago
What is the bug that can result from the "for(var i=0)" pattern? None, beause browsers ignore the second var for the same variable and do te ituitively right thing.
What's the bug that results from the "var i; for(i=0)" pattern? Someone refactors the "var i" away and you end up with a global var.
So, really, while the pedantic answer is to forbid the pattern, the pragmatic answer is to recommend it.
- ahoge 14y ago>What's the bug that results from the "var i; for(i=0)" pattern? Someone refactors the "var i" away and you end up with a global var. Wrong. JSLint will complain and then you'll fix it. That's why you use JSLint. It can find stupid things like this easily and accurately.