how to declare variable in javascript
<pre><code>$("#btnsub").click(function () {
    var add = $("#txtname").val();

    var obj;
    var geo = new google.maps.Geocoder;
    geo.geocode({ 'address': add }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            obj = results[0].geometry.location;
            obj = convert(obj);
            alert(obj);
        } else {
            alert("Geocode was not successful for the following reason: " + status);
        }
    });
    alert(obj);
  // why this alert run first instead of the upper alert()
});
</code></pre>
