> geolocator.getLatLng("Forest Park, St. Louis, MO", function(center) {<p>> displayMapAt(center, 14);<p>> });<p>To my eyes, that solution is just fine. I don't think I'll ever be swayed to believe that adding on layers of indirection to JavaScript code for the sake of "syntactic goodness" is rationally motivated by leading to more practical power for actually solving problems.
You should probably assign an object to the underscore, otherwise any argument which is undefined will match:<p><pre><code> js> var _
js> _ == undefined
true
</code></pre>
Just doing "var _ = {}" should be sufficient.<p><i>edit: however, this conflicts with Underscore.js (<a href="http://documentcloud.github.com/underscore/" rel="nofollow">http://documentcloud.github.com/underscore/</a>), but if you put an "if (typeof _ === "undefined")" around the assignment you should be ok</i>
Can someone explain why this:<p><pre><code> geolocator.getLatLng("Forest Park, St. Louis, MO", displayMapAt);
</code></pre>
Is better than this?<p><pre><code> displayMapAt(geolocator.getLatLng("Forest Park, St. Louis, MO"));
</code></pre>
That is, why is it more sensible for getLatLng to accept a callback function that will accept its result, when one can just pass its result to a function?