Using debugger statements in your JavaScript Code

Using debugger statements in your JavaScript Code

Philipp Nowinski 04. Oktober 2016 Tipps & Tricks

0 Kommentare // Lesezeit: 1 min.

Debugging JavaScript Code can quickly become a cumbersome issue. We have powerful tools like the Chrome Devtools at our disposal and yet – most of the time I find myself putting console.log statements in my code whenever I need to isolate a problem. I could easily head over to the devtools, put a breakpoint at the desired line in my code an use the full featureset of a real debugger, but somehow, it never seemed convenient enough for me.

The other day, I stumbled upon an interesting JavaScript feature that has actually been around for a while. By putting a debugger; statement in your code, you can force the browser to jump into the debugger if the devtools are open. Just like you set a breakpoint inside the devtools.


Nice! – That seems much more convenient to me :-) Instead of having to leave my code and head over to the devtools, I can just put the debugger statement in there like I would do with console.log. I now find myself using the debugger a lot more often and since it is a far more powerful tool than simple console.log statements, it might speed up my productivity a notch in the long run. Once again, it's the little things that matter, right? :-)

0 Kommentare

Dateien hier ablegen
Dateien hochladen
Keine Kommentare.