title: What is the correct function callback syntax?
body: <p>In javascript, how do I write the call to a function, with a callback, when the function has at least one parameter?</p>
  
  <p>When using callbacks, the following is what I understand:</p>
  
  <pre><code>var result = foo();
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>foo(function(result) {
      // code that depends on 'result'
  });
  </code></pre>
  
  <p>However, if <code>foo</code> takes a parameter, how should the call to <code>foo</code> be written?</p>
  
  <p>Is it something along the lines of the following:</p>
  
  <pre><code>var result = foo(testdata);
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>foo(function(result), testdata {
      // code that depends on 'result'
  });
  </code></pre>
  
  <p>or </p>
  
  <pre><code>foo(function(result, testdata){
      // code that depends on 'result'
  });
  </code></pre>
  
  <p>I am not sure on the correct syntax. Can someone please point me to a resource or help me with the correct syntax?</p>