Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

If you execute this code:

var foo = {bar: 'baz'};
window.console.log(foo);
foo.bar = 'bla';

The console shows this after expanding the object:

(when logging objects and arrays, it's not the run-time value that's recorded)

This bug was documented over a year ago:

http://code.google.com/p/chromium/issues/detail?id=50316

Is there a workaround for logging objects in Chrome?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
206 views
Welcome To Ask or Share your Answers For Others

1 Answer

I just use JSON.stringify when i need it. Don't know if it will do it for you, but it is easy and effective for debugging purposes.

This is no good for objects with function references in it tho, so if you need that i would consider using either a deep copy of the object (you can use jQuery's excellent extend method) or roll you own logging function that will loop recursively over the object and print it out.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...