title: Return undefined value in javascript function
body: <p>I have following code:</p>
  
  <p>js load:</p>
  
  <pre><code>&lt;script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>js function:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      var get_location;
  
      function get_google_latlng() {
  
          var geocoder =  new google.maps.Geocoder();
          geocoder.geocode( { 'address': 'iran'}, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                  window.get_location = results[0].geometry.location.lat();
              } else {
                  window.get_location = status;
              }
          });
  
          return window.get_location;
      }
  
      var lat = get_google_latlng();
  
      alert(lat);
  &lt;/script&gt;
  </code></pre>
  
  <p>return Function is <code>undefined</code><br /></p>
  
  <p><code>window.get_location</code> command also does not work.</p>