I am a javascript newbie and trying this code in javascript(using jQuery) :
$(document).ready(function() {
var nodes=[];
$.getJSON('/get/data', function(data) {
            nodes.push(data);
        });
//debugger
console.log(nodes);
console.log(nodes[0]);
});
This is what I see in console:
[ ]
undefined
But when I uncomment //debugger and run it, I get these results:
  []
  []
  []
 [[Object { id=10,  label="foo"}, Object { id=9,  label="bar"}, 43 more...]]
 [Object { id=10,  label="foo"}, Object { id=9,  label="bar"}, ...]
What is going on? I can't understand how activating the debugger can affect a variable and make it defined or undefined. By the way, this is just part of a larger script so it may be a factor.
 
    