Thursday, July 17, 2014; 11:29:59 AM Eastern
Gobal JavaScript for loop index
- I just learned that this:
for (i = 0; i < subs.length; i++)
- Is very different from:
for (var i = 0; i < subs.length; i++)
- Especially if it's in a recursive routine.
- In the first case, i is a global. In the second it's local.
- You might argue that the first case is useless and the language should only allow locals in that spot.
- But this is JavaScript.
- There should be a special smiley that you put after that last sentence. ;-)