title: javascript for loop variable and recursion
body: <p>I have an issue where I have recursion inside of a for loop:</p>
  
  <pre><code>function func(node) {
      for(var i = 0; i &lt; node.children.length; i++) {
         func(node.children[i]);
      } 
  } 
  </code></pre>
  
  <p>Obviously because JavaScript does not have block scope, the same i variable is getting modified each time the function is called.  What is the best way to remedy this?  Assume regular EcmaScript 3 and I can't use JavaScript 1.7 "let".  </p>
  
  <p>I know this has been asked before, but the other questions don't seem to show recursion, they show one function call where a closure could be used.</p>