3 ms·
Also, putting 'var' in a loop header is debatable because it gives the false impression that the variable "i"'s scope is confined to the for loop, when in reali
by 727374 13y ago
Also, putting 'var' in a loop header is debatable because it gives the false impression that the variable "i"'s scope is confined to the for loop, when in reality it will be alive throughout the containing function. JSLint would bark.
- xiaoma 13y agoI don't think it gives that impression at all. In JavaScript the rules for scope are clear—it's lexical scoping nested at the function level. Loops, conditionals, etc... have no bearing on scope.