Reputation: 10622
I have a piece of JavaScript code running in browser and I want to pause it to see what values are in the console.
I have a lot of logs going on so I need to see whats logged at a certain point through running the script.
I am running chrome, is there a button or shortcut to do this ?
Upvotes: 1
Views: 4014
Reputation: 4085
Console
tabsetInterval(() => { debugger; }, 5000)
Now make the page to be on the state that you want (open drawers, open gallery menus, etc...) after 5 seconds (you can tweak this 5 seconds by changing 5000
to other numbers 5 * 1000 = 5000
) website will freeze.
Now do what you wanna do with the site!
Upvotes: 2
Reputation: 5971
Whenever you want to add breakpoint enter the following in debug console (F12
in Chrome):
debugger;
It works in most browsers.
Upvotes: 3
Reputation: 330
F12 brings the Developer Tools. There, go to Sources and pick your source script. You may either change some lines to include a debugging directive, namely
debugger
which will pause the processing and let you fiddle around.
There is also a possibility of signing a line where you want to pause, by simply clicking on the line's number in source view in the developer tools.
Upvotes: 1
Reputation: 22158
You must to use developer tools. If you use the debugger you can put break points and pause in exceptions. You can view variable values, objects structure, and much more information.
Maybe this link is useful for you: https://developer.chrome.com/devtools/docs/javascript-debugging
Good luck
PD: Note that firefox's developer tools are better and more complete than chrome developer tools, but in essence are for the same purpose.
Upvotes: 1
Reputation: 19967
This is what you are looking for.
https://developer.chrome.com/devtools/docs/javascript-debugging
You can pause scripts and hover your mouse over to see variable values at that point in the script. Enjoy.
Upvotes: 1