Javascript watch based on breakpoint with Firebug?

Work through some event routing right now and there are many debugging steps.

I know about using a "debugger" in javascript and put it after the conditional, and this is useful. I also know that I need to click the breakpoint to add a test expression that is even better. However ... I have no idea where this will take me, and I'm starting to wear out my function keys. Is there any way to add a breakpoint to the clock expression?

Basically the idea is that in the shell area, I want to check a variable called this.id. If this.id is the value I want, I enter the debugger.

Any ideas?

thanks

I would like to add that Didier's answer below solved my problem, as they are described in the article to decorate "Function". This will most likely be the path of least resistance to find all the functions for the value I want.

Function.prototype.debug = function(){ var fn = this; return function(){ if (debugme) debugger; return fn.apply(this, arguments); }; }; 
+6
source share
3 answers

To programmatically break javascript code, you can use the following statement:

 debugger; 

This works in Firebug, the Chrome console, and IE.

So, following your question, you can do something like:

 if (this.id === "myId") debugger; 

The following article is quite helpful.

+4
source

If you refer to " conditional breakpoints ", that is, a breakpoint that pauses execution only when the statement is true, you can do this by right-clicking on the script line and selecting "Change interrupt condition ...", then adding the statement you want to call the breakpoint, for example this.id === "foo";

+4
source

I do not 100% understand how you need it, it differs from a conditional breakpoint. e.g. adding

  var watchVar = this.id 

then set the condition for the breakpoint

 watchVar == someInt 

should work no?

If not, you can break the property change by setting a normal breakpoint somewhere in the close. When you click it, find this.id in the clock panel, right-click on it and select "break in property change". At the moment, this is about the way you can go, but it does not allow you to specify some id values, not others.

+1
source

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


All Articles