title: Cast from object to function
body: <p>Suppose I have a javascript function of the form:</p>
  
  <pre><code>function(){alert("blah");}
  </code></pre>
  
  <p>Suppose I also have an applet, which has a method called doStuff that takes the function as a parameter:</p>
  
  <pre><code>MyApplet.doStuff(function(){alert("blah");});
  </code></pre>
  
  <p>Now suppose that the applet passes the function to a success or failure javascript callback function depending on the result of its calculations.  In that callback function, I want to execute the function so that the user gets my exceedingly informative "blah" message:</p>
  
  <pre><code>function callback(func) {
    func();
  }
  </code></pre>
  
  <p>However, in the example above, func is no longer considered to be of type "function" (typeof func will return "object").  Is it possible to convert func to be a function so that it can be executed?  I have a number of hacks in mind that can give me what I want, but they are very ugly and I was hoping that I was missing something simple.</p>
  
  <p>Any help is greatly appreciated.</p>