title: What's the best practice for passing a Javascript function with parameters without executing it?
body: <p>What's the most efficient/the best practice for passing a Javascript function with parameters without executing it, and why? Here is the choice I know :</p>
  
  <p><strong>Make a anonymous method</strong></p>
  
  <pre><code>jQuery("#target").click(function() {
      onTargetClick("myCoolParam");
  });
  
  function onTargetClick(coolParam) {
      // some epic code...
  }
  </code></pre>
  
  <p><strong>Use partial function application</strong>
  (See: <a href="https://stackoverflow.com/questions/373157/how-can-i-pass-a-reference-to-a-function-with-parameters">Partial function application</a>)</p>
  
  <pre><code>jQuery("#target").click(partial(onTargetClick, "myCoolParam"));
  
  function onTargetClick(coolParam) {
      // some epic code...
  }
  
  function partial(func /*, 0..n args */) {
      var args = Array.prototype.slice.call(arguments).splice(1);
      return function() {
          var allArguments = args.concat(Array.prototype.slice.call(arguments));
          return func.apply(this, allArguments);
      };
  }
  </code></pre>
  
  <p><strong>EDIT for the partial function</strong></p>
  
  <pre><code>function partial(func /*, 0..n args */) {
      var args = Array.prototype.slice.call(arguments, 1);
      return function() {
          var allArguments = args.concat(Array.prototype.slice.call(arguments));
          return func.apply(this, allArguments);
      };
  }
  </code></pre>
  
  <p>Thank you for your help.</p>