title: Nesting functions and performance in javascript?
body: <p>Some of coworkers are saying that nesting functions is bad for performance and I wanted to ask about this.</p>
  
  <p>Lets say I have the function:</p>
  
  <pre><code>function calculateStuff() {
      function helper() {
      // helper does things
      }
      // calculateStuff does things
      helper();
  }
  </code></pre>
  
  <p>helper is a private function that is only used inside calculateStuff. That's why I wanted to encapsulate this inside calculateStuff.</p>
  
  <p>Is this worse performance wise than doing:</p>
  
  <pre><code>function helper() {
  
  }
  
  function calculateStuff() {
      helper();
  }
  </code></pre>
  
  <p>Notice that in the second case, I expose helper to my scope.</p>