JavaScript :How to set a Conditional Break Point in Chrome debugger tools

I have this simple a js file , which prints date continosly .

I am using Google Chrome Debugger tools (F12)

My question is , Is it possible to set a conditional break point in Google Chrome ??

In my code , i want to set a break point if the seconds value is equal to 50 ??

s = date.getSeconds();

This is the jsfiddle where my source is

(Not sure why its not working in jsfiddle)

Anyway my question is ,Is it possible to Set a Conditinal Break Point in chrome Debugger tools ??


Yes, it is possible.

Right click the marker of the breakpoint and select "Edit breakpoint..." there you can set the condition.

From Chrome Developer Tools on Breakpoints at developers.google.com (Emphasis mine):

Note: All the breakpoints you have set appear under Breakpoints in the right-hand sidebar. Clicking on the entry jumps to the highlighted line in the source file. Once you have a breakpoint set, right click on the blue tag breakpoint indicator to set a conditional statement for that breakpoint. Type an expression and the breakpoint will only pause only if the condition is true.


Take a look at debugger statement. Basically it invokes any debugger tools available, and in Chrome it acts as if interpreter met a breakpoint.

Your code would be:

s = date.getSeconds();
if (s == 50) {
   debugger;
}

From reference:

[debugger] Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.


You can set a conditional break point in Google Chrome, by following these steps:

1.right click the breakpoint where u want to stop,please chk on enter image description here

2.click "Add conditional breakpoint",one text will be appear,there u can add condition (the result will be 'true' if the condition satisfied ,else 'false'), the breakpoint color will goto orange after the condition added,chk on enter image description here

3.reload same page u can see the breakpoint will work if the condition is satisfied like enter image description here