title: Getting a better understanding of callback functions in JavaScript
body: <p>I understand passing in a function to another function as a callback and having it execute, but I'm not understanding the best implementation to do that. I'm looking for a very basic example, like this:</p>
  
  <pre><code>var myCallBackExample = {
      myFirstFunction : function( param1, param2, callback ) {
          // Do something with param1 and param2.
          if ( arguments.length == 3 ) {
              // Execute callback function.
              // What is the "best" way to do this?
          }
      },
      mySecondFunction : function() {
          myFirstFunction( false, true, function() {
              // When this anonymous function is called, execute it.
          });
      }
  };
  </code></pre>
  
  <p>In myFirstFunction, if I do return new callback(), then it works and executes the anonymous function, but that doesn't seem like the correct approach to me.</p>