Synchronous console logging in Chrome

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.

Answers:

Answer

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

Answer

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"}

Answer

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

enter image description here

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.