title: Best way to setup optional callbacks in a function
body: <p>What is the best practice for optional success and error callbacks in a function like this? Does this method make sense? It seems a little bloated to me.</p>
  
  <p><strong>Function Declaration:</strong></p>
  
  <pre><code>var myFunc = function(myNumber, options){
      options = options || {};
      options.onSuccess = options.onSuccess || function(){};
      options.onError = options.onSuccess || function(){};
  
      var myNewNumber = myNumber * 2;
  
      if(newVar &gt; 10){
          options.onSuccess(myNewNumber);
      }else{
          options.onError(myNewNumber);
      }
  }
  </code></pre>
  
  <p><strong>Calling it with callbacks:</strong></p>
  
  <pre><code>myFunc(2,{
      onError: function(myNewNumber){
          // do stuff
      },
      onSuccess: function(myNewNumber){
          // do stuff
      }
  })
  </code></pre>
  
  <p><strong>Calling it without callbacks:</strong></p>
  
  <pre><code>myFunc(2);
  </code></pre>