If I have a pair of functions that both set local variables, for example, the variable i in common for loops, and one happens to be called while the other is running, is there any danger of namespace confusion?
If I have a pair of functions that both set local variables, for example,
Share
As long as you’re using
var, like this:Then it’s local and you’re fine, if you don’t use
var, you have a global variable on your hands, and potential issues. Also if aforloop is nested in another, you should use a different variable name for each loop.