Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a JavaScript breakpoint from code in Chrome?

I want to force the Chrome debugger to break on a line via code, or else using some sort of comment tag such as something like console.break().

like image 871
Paul Avatar asked Apr 06 '12 23:04

Paul


People also ask

How do you enter a breakpoint in code?

To set a breakpoint in source code, click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.

Can you set breakpoints in JavaScript?

In the debugger window, you can set breakpoints in the JavaScript code. At each breakpoint, JavaScript will stop executing, and let you examine JavaScript values. After examining values, you can resume the execution of code (typically with a play button).


1 Answers

You can use debugger; within your code. If the developer console is open, execution will break. It works in firebug as well.

like image 161
xn. Avatar answered Oct 16 '22 02:10

xn.