最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Synchronous console logging in Chrome - Stack Overflow

programmeradmin1浏览0评论

Is it posible to make logging to the console synchronous? I often run into situations where the code execution is faster than dumping the structures. That resolves in outputting already changed objects.

I sure can walk through the code with debugger, make unit tests etc., it's just often convenient to simply console.log stuff just to make a general idea of what is going on.

Is it posible to make logging to the console synchronous? I often run into situations where the code execution is faster than dumping the structures. That resolves in outputting already changed objects.

I sure can walk through the code with debugger, make unit tests etc., it's just often convenient to simply console.log stuff just to make a general idea of what is going on.

Share Improve this question asked Apr 6, 2012 at 8:11 Mikulas DiteMikulas Dite 7,9419 gold badges61 silver badges102 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 11

You could create a copy of the object before passing it to console.log. Look here for a function to create a deep copy of your object.

Edit:

Now implemented in Chrome, see here

I just got caught by this behaviour, spent some hours until I realized the console is borked, not my code. damn.

Until now I only managed to get expected behaviour with:

console.log(JSON.stringify(obj))

nice side effect is, it expands the objects like {0: "a", 3: "b"}

Put a breakpoint(see image below) at console.log statement and use controls to step over to next.

发布评论

评论列表(0)

  1. 暂无评论