Javascript object properties visible in console, but undefined?
<p>I'm having trouble figuring out how to access object properties in Javascript.  I have a function that returns an object, and I can see that object and all of its properties when it is logged to the console in Safari, but I can't get the property values for other functions.  For example trying to alert out one of the properties returns 'undefined'.</p>

<p>The function that generates a object</p>

<pre><code>
getProfile : function() {

  FB.api('/me', function(response) {
    facebook.profile.user_id = response.id;
    facebook.profile.name = response.name;
    facebook.profile.firstName = response.first_name;
    facebook.profile.lastName = response.last_name;
    facebook.profile.gender = response.gender;
  });

  FB.api('/me/photos', {limit: 8}, function(response) {
    facebook.profile.numPhotos = response.data.length;
    for (key in response.data) {
      var photoUrl = response.data[key].source;
      eval('facebook.profile.photo' + key + '= photoUrl');
    }
  });

  return facebook.profile;
}
</code></pre>

<p>Trying to use that function in another script
<code><pre>
function loadProfile() {
  var profile = facebook.getProfile();</p>

<p>console.log(profile);
  alert(profile.name);
}
</pre></code></p>
