Synchronous console logging in Chrome

Can I record to the console synchronously? I often come across situations where code execution is faster than dumping structures. This allows the output of already modified objects.

I am sure that I can go through the code using the debugger, do unit tests, etc., it’s just often convenient just to console.log to just get a general idea of ​​what’s going on.

+6
source share
3 answers

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

Edit:

Now implemented in Chrome, see here .

+10
source

I just caught this behavior, spent several hours until I realized that the console was broken, and not my code. pancake.

So far, I have managed to get the expected behavior with:

 console.log(JSON.stringify(obj)) 

good side effect, it expands objects like {0: "a", 3: "b"}

+7
source

Place the breakpoint (see the figure below) in the console.log statement and use the controls to go to the next.

enter image description here

+2
source

Source: https://habr.com/ru/post/912572/


All Articles