How do you inspect Javascript objects, say, in console output?
I thought I new the right answer - most browsers will show object
values in console output by just passing the object.
However, there is a fatal flaw - at least with Safari. The value
shown is the CURRENT value of the object, NOT the value at the time it
was logged! So, if the object was changed subsequent to logging, when
you go to look at the log the object content will not be correct. The
only time it can be guaranteed correct is if the debugger is paused
immediately after the console.log() call.
I've seen suggestions to use JSON.stringify() but
that can't deal with cyclic data structures, which are pretty
common on Javascript and jQuery.
I've just tried something called jquery.inspect, but it
has not been updated in 4 years. And it does rather more than I want -
for example, it will dump the entire source of any functions in the object.
What do you use if you want to log objects, without having to
breakpoint? (If I have to breakpoint, I might as well just inspect in
the browser tools, rather than logging.)