Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Indeed. Learning that

    debugger;
will stop the interpreter at any point you like, with console scoped at that point, has sped up my JS'ing greatly


Wait you can what!?? Holy moly, I've been writing JS for like 3 years now and I never knew this.


Yep - as long as dev tools are open. Works everywhere, even in eg. underscore templates, backbone init functions..


chrome extension content scripts...


You should watch Discover DevTools then.


Holy shit! I've been programming in JavaScript for years and never heard about the debugger statement. This looks great for really understanding the details of JavaScript's object model.


Also that little stop sign shaped pause button in Chrome will 'Pause on all exceptions' (blue) or 'Pause on all uncaught exceptions' (purple, I usually leave it on this).


Doesn't a breakpoint do exactly the same thing?


Yep! I find it easier to use the debugger statement though when changing code a lot. Also, some places like compiled templates are difficult to set the breakpoint so it's useful there too.


Just watch out, we get these committed semi-frequently. Whoops!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: