title: Private functions in JavaScript
body: <p>In a jQuery-based web application I have various script where multiple files might be included and I'm only using one of them at a time (I know not including all of them would be better, but I'm just responsible for the JS so that's not my decision). So I'm wrapping each file in an <code>init<i>Module</i>()</code> function which registers various events and does some initialization etc.</p>
  
  <p>Now I'm curious if there are any differences between the following two ways of defining functions not cluttering the global namespace:</p>
  
  <pre><code>function initStuff(someArg) {
      var someVar = 123;
      var anotherVar = 456;
  
      var somePrivateFunc = function() {
          /* ... */
      }
  
      var anotherPrivateFunc = function() {
          /* ... */
      }
  
      /* do some stuff here */
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>function initStuff(someArg) {
      var someVar = 123;
      var anotherVar = 456;
  
      function somePrivateFunc() {
          /* ... */
      }
  
      function anotherPrivateFunc() {
          /* ... */
      }
  
      /* do some stuff here */
  }
  </code></pre>