title: Save the latitude and longitude in an object
body: <p>I want to save the latitude and longitude in an object. When I use the first console.log it shows me the latitude and longitude too.</p>
  
  <p>When I try to save in a variable and use console.log after the function it shows me nothing.</p>
  
  <p>Whats wrong? I read that is for <strong>async programming</strong> but I don't get it.</p>
  
  <pre><code>$(document).ready(function(){
  var userPosition = 
  {
      lat: '',
      lon: ''
  };
  
      if(navigator.geolocation)
          {
              navigator.geolocation.getCurrentPosition(function(position){
                  userPosition.lat = position.coords.latitude;
                  userPosition.lon = position.coords.longitude;
                  console.log(userPosition.lat); //This shows me the latitude
              });
          }
          else
          {
              alert("Geolocation not supported by your browser");
          }
  
  console.log(userPosition.lat);      // This not works
  
  });
  </code></pre>