title: Beginner Javascript: What's the difference between 'function xyz(){}' and 'var xyz = function(){}'?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/336859/javascript-var-functionname-function-vs-function-functionname">JavaScript: var functionName = function() {} vs function functionName() {}</a>  </p>
  </blockquote>
  
  
  
  <p>I've been going through CodeAcademy's Javascript courses, and a few things have gone over my head. I understand how function work, and I'm trying to wrap my head around OOP and objects/methods. </p>
  
  <p>My question is, what's the difference between creating a function like this:</p>
  
  <pre><code>function countTo(number){
      for (var i=1; i&lt;=number; i++){
          console.log(i);
      }
  }
  
  countTo(15);
  </code></pre>
  
  <p>and creating a function like this:</p>
  
  <pre><code>var countToTwo = function(number){
      for (var i=1; i&lt;=number; i++){
          console.log(i);
      }
  };
  
  countToTwo(27);
  </code></pre>
  
  <p>Both do the same thing and have the same output. Are they exactly the same/interchangeable? Does it matter which one I use when creating a function? </p>