Can the JavaScript debugger do "when this variable is read", is there a breakpoint there?

Can a JavaScript debugger do "when this variable is read", the breakpoint is there, like a C / C ++ debugger?

I call some library function, and at heart it finally does something with this argument, and instead of manually finding where it actually uses this value, can I say stop the code when accessing the variable?

+3
source share
5 answers

Try defining a getter for your variable. A receiver is a piece of code that runs whenever someone accesses the value of an object. (This relatively new JavaScript feature is not available in IE, but if you just use it for debugging in Firefox, everything will be fine.)

Your recipient can simply return a value, but you can set a breakpoint in your recipient. Or, even better, you can get getter to run the debugger statement to stop automatically.

+5
source
0
source

.

, Firebug . DOM.

0

Firefox Firebug . , , "", " " , .

0

, , , , ? , JS.

-1

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


All Articles