Can a JavaScript debugger do "when this variable is read", break point there, like a C / C++ debugger?
I am calling some library function, and deep down, it is finally doing something with that argument, and instead of manually finding where it is actually using that value, can I say, stop the code when the variable is accessed?
Try defining a getter for your variable. A getter is a piece of code that runs whenever someone accesses an object's value. (This relatively new JavaScript feature is not available in IE, but if you're just using it for debugging in Firefox it should be fine.)
Your getter may simply return the value, but you can set a breakpoint in your getter. Or, even better, you can have the getter run the debugger statement to halt automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With