JavaScript object returned from function available in Chrome Dev Tools, but not from script
<p><strong>EDIT</strong></p>

<p>I was a bit quick there, the problem arises in the function and not where I first said. Here is the function:</p>

<pre><code>function returnAnObject(url) {
  var apiurl = 'http://url.com';

  var info = {};
  $.getJSON(apiurl, function(data) {
    $.extend(info, {
      a  : data.x,
      b  : data.y,
      c  : data.z
    });
  });

  console.log(info); // Shows object as usual
  console.log(info.a); // Shows undefined
  return info;
}
</code></pre>

<p>Does that make it clearer?</p>

<p><em><strong>END EDIT</em></strong></p>

<p>Ok so, I have a little problem.</p>

<p>I have a function that returns a fairly simple object, which looks something like this:</p>

<pre><code>{
  a: 'x',
  b: 'y',
  c: 'z'
}
</code></pre>

<p>I save it to a variable like this:</p>

<pre><code>var something = functionThatReturnsObject(someargument);
console.log(something); // In chrome dev tools, I see the object and its values
console.log(something.a); // This, however, logs undefined
console.log(something['a']); // This also logs undefined
</code></pre>

<p>Why is this? I think I'm going crazy here, I must have overlooked something...</p>

<p>The really weird part happens if instead of</p>

<pre><code>var something = functionThatReturnsObject(someargument);
</code></pre>

<p>I write</p>

<pre><code>window.something = functionThatReturnsObject(someargument);
console.log(something); // Still works, showing the object and properties
console.log(something.a); // Still doesn't work
console.log(someting['a']); // Still doesn't work
</code></pre>

<p>If I now access the object directly from the dev tools, inputting</p>

<pre><code>something; // returns object, I can see everything in it etc.
something.a // Now, for some mysterious (to me) reason, this works, returning the value of a
</code></pre>

<p>So, does anyone understand what is going on here?</p>
