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 ?
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 ?
Share Improve this question asked Aug 19, 2015 at 12:19 thatOneGuythatOneGuy 10.7k9 gold badges58 silver badges92 bronze badges5 Answers
Reset to default 3Whenever you want to add breakpoint enter the following in debug console (F12
in Chrome):
debugger;
It works in most browsers.
- Open Developer Tools (Ctrl + Shift + I)
- Go to
Console
tab - Paste this to the console:
setInterval(() => { 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!
This is what you are looking for.
https://developer.chrome./devtools/docs/javascript-debugging
You can pause scripts and hover your mouse over to see variable values at that point in the script. Enjoy.
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./devtools/docs/javascript-debugging
Good luck
PD: Note that firefox's developer tools are better and more plete than chrome developer tools, but in essence are for the same purpose.
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.