Possible Duplicate:
console.log object at current state
I understand basic synchronous and asynchronous behavior:
// this block gets executed all at once the next time the js engine can run it
setTimeout(function() {
var snacks = "cookies";
snacks += "and popcorn";
console.log("goodbye world");
}, 0);
console.log("hello world"); // this block runs before the block above
What I don't understand why the first console here reports[]:
var x = [];
x.push({ a: "c" });
console.log(x); // says []
x.splice(0, 1);
console.log(x); // says []