Is it bad practice to use the same variable name in multiple for-loops?
I was just linting some JavaScript code using JSHint. In the code I have two for-loops both used like this: for (var i = 0; i < somevalue; i++) { ... } So both for-loops use the var i for iteration. Now JSHint shows me an error for the second for-loop: "'i' is already defined". I can't say that this isn't true (because it obviously is) but I always thought this wouldn't matter as the var i is only used in that specific place. Is it bad practice to use for-loops this way? Should I use a different variable for each for-loop in my code like //for-loop 1 for (var i = 0; ...; i++) { ... } //for