title: JavaScript/JQuery - can you pass a reference to a function and then execute it?
body: <p>Based on the JavaScript example below, is there a way to pass a reference to function <code>f</code> to the <code>promptForProceed</code> function and have it conditionally executed in <code>promptForProceed</code>?</p>
  
  <p>Could you also do this if the <code>f</code>function took some parameters (ie: <code>f(a, b, c) { ... }</code>)?</p>
  
  <pre><code>function f() {
      //Do stuff..
  }
  
  function promptForProceed(myFunction) {  // &lt;------ PASS FUNCTION AS PARAMETER
      $("#div-dialog-proceed").dialog({
          modal: true,
          buttons: {
              "Stay on current page": function () {
                  $(this).dialog("close");
              },
              "Continue": function () {
                  $(this).dialog("close");
                  myFunction(); // &lt;---------  CALL FUNCTION
              }
          }
      });
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Update</strong>: Think I like the option of using an anonymous function parameter:</p>
  
  <pre><code>promptForProceed(function() { //Do stuff like call f(a,b,c) });
  </code></pre>