I am working on some JavaScript - of course! - and am doing some debugging in Chrome.
Now, I would like to enable a break-point programatically when a function (with a given name) is called.
It should function like a break-point. The debugger keyword always breaks (uhg!) and is an ugly artifact to put in and remove from code.
It should not require manual source code navigation / interactivity. Since the source is combined through an automated build process this becomes a time-consuming endeavor.
Ideally it would be as something as simple and programatically controlled, eg.
Debugger.setBreakpoint({onFunction: "Foo.prototype.bar"})
Is there a way to set a break-point for when a particular (named) function is called without manual navigation of the currently loaded script?
If not as envisioned programatically, is there a way to set a break-point via a comment? (Break-point, not debugger-break.)
(I am amendable to using similar developer tools in another browser, as long as it runs on Windows - but a Chrome solution, if such exists, is ideal.)
In Chrome Developer Tool you can use debug(function) statement to invoke function and break inside of it.
One more way if you have a exact function referencevar func = function(){
if (arguments.callee._debug) {
debugger;
}
}
set _debug flag to truefunc._debug = true
then function func() will be stopped. It's tricky and this will not work it strict mode.
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