I find myself getting tripped up by console.log()
a lot, because of it's asynchronous nature.
By that I mean it's tendency not to capture a variable's value at a specific point in time.
It work's fine for simple values because assignment to a variable with an immediate value binds the variable to an entirely new object., e.g.
var x = 3;
console.log(x); //prints 3
x=4;
But when you start working with objects that are bound by reference, things get... counter-intuitive. e.g.
var obj = {x: 3};
console.log(x); //prints 4!
obj.x = 4;
Is there some other logging function I can use that will provide me with the state of an object at the time of invocation in terms of my code? I'm looking for something that's either synchronous or at least appears to be from the result it yields.
I'd be nice if it worked cross platform, but I would be happy just to get one that works in chrome.