adding callback to function - always
<p>I found myself using a weird way to add callback functions to my functions and I was wondering if there is a more generic way to add callbacks to functions, best case I would have a situation where all of my functions check the last given param for being a function and if so use it as a callback.</p>

<p>This is how I did it in the past:</p>

<pre><code>var myFunc = function( obj ) {

  if ( arguments.length &gt; 0 ) {
    if ( _.util.typeofObj( arguments[arguments.length-1] ) === Function ) {
      var callback = arguments[arguments.length-1];
    }
  }

  // some code ...

  if ( callback !== undefined ) {
    callback();
  }

};

var foo = myFunc( myObj, function(){
  alert( 'Callback!' );
});
</code></pre>

<p>Any suggestions?</p>
