title: Define local function in JavaScript: use var or not?
body: <p>When a local (inner) function is declared in JavaScript, there are two options:</p>
  
  <p>Declaring with <code>var</code> keyword, assigning to the variable:</p>
  
  <pre><code>(function() {
      var innerFunction1 = function() { ... };
      innerFunction1();
  }());
  </code></pre>
  
  <p>Declaring just with the <code>function</code> keyword, without assigning to variable:</p>
  
  <pre><code>(function() {
      function innerFunction2() { ... };
      innerFunction2();
  }());
  </code></pre>
  
  <p>I can see one advantage of the second: the function can be declared below the code which calls it so it is easier to separate private functions from the code actually executed. </p>
  
  <p>Which of them is <strong>better</strong> and <strong>why</strong>? </p>