title: Difference between passing a function as an argument and calling a function
body: <p>I'm trying to understand why its necessary to pass a function as an argument in order to be utilized as a callback function. What is the difference if I simply call the function directly within the parent function. </p>
  
  <p><a href="http://jsfiddle.net/7Lsafchu/5/" rel="nofollow">http://jsfiddle.net/7Lsafchu/5/</a></p>
  
  <pre><code>function main(statement, callback) {
      $("body").append("Statement: " + statement + "\n");
      callback();    
  }
  
  function anyFunction() {
          $("body").append("&lt;p&gt;I'm writing to a wall&lt;/p&gt;");
  }
  
  main("This is test 1",anyFunction);
  
  
  function main2(statement, callback) {
      $("body").append("Statement: " + statement);
      anyFunction2();    
  }
  
  function anyFunction2() {
          $("body").append("&lt;p&gt;I'm writing to a wall Again&lt;/p&gt;");
  }
  
  main2("This is test 2");
  </code></pre>