admin管理员组文章数量:1306821
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:
Is there a workaround for logging objects in Chrome?
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./p/chromium/issues/detail?id=50316
Is there a workaround for logging objects in Chrome?
Share Improve this question asked Sep 22, 2011 at 21:48 Ed MazurEd Mazur 3,1023 gold badges24 silver badges21 bronze badges 1-
A simple solution could be to override
console.log
and with a function that clones and logs the input (although it would probably be a shallow copy). – Felix Kling Commented Sep 22, 2011 at 21:50
2 Answers
Reset to default 9I 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.
You could use a dedicated logging library such as my own log4javascript.
本文标签: javascriptWorkaround for logging objects to console in ChromeStack Overflow
版权声明:本文标题:javascript - Workaround for logging objects to console in Chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741828404a2399784.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论