Return value when passing a function as an argument in Javascript
<p>I have some javascript code that works fine when I pass an object to a method. In <a href="http://docs.angularjs.org/#dsq-login-google" rel="nofollow">the API documentation</a>, it says that I can also pass a function to the method. When I try this, I'm able to pass parameters and do an alert to verify that the parameters are being passed. However, I'm not able to return the value. </p>

<p>What is the line of javascript that I'm missing to properly return the value?  </p>

<pre><code>var result = {model: "todo"};

//$httpBackend.whenGET(/^\/api\//).respond(result);
$httpBackend.whenGET(/^\/api\//).respond(do_something);

function do_something(method, url, data) {
    alert("url "+url); // or whatever
    var result =  {model: "todo"};
    return result;
}

//From the API documentation
//   $httpBackend.whenGET('/.*/').respond(function(method, url, data) {
//     do something
//});
</code></pre>
