title: JavaScript parent variables value irregularities?
body: <p>I have the following code:</p>
  
  <pre><code>var address;
  getAddress(0,0);
  function getAddress(latlng) 
  {
    if (latlng != null) 
    {
      geocoder.getLocations(latlng, 
      function(addresses) 
      {
        if(addresses.Status.code == 200) 
        { 
          address = addresses.Placemark[0].address.toString();
          alert(address);  // Outputs something :)
        }
      });
     }
     return address;   //returns nothing :(
  }
  </code></pre>
  
  <p><code>address</code> always returns <code>undefined</code> but the alert does output something. Why is this?</p>
  
  <p>(Geocoder is an instance of <a href="http://code.google.com/apis/maps/documentation/reference.html#GClientGeocoder" rel="nofollow noreferrer">Google Maps APIs</a>)</p>