DEV Community


Discussion on: Jan. 17, 2020: What did you learn this week?

richardeschloss profile image
Richard Schloss

I learned that javascript has a built-in keyword "debugger" so that wherever you write that word, the debugger will stop at that point in code (if you have a debugger, such as the Chrome dev tools debugger). This can be useful if your runtime code is uglified, as in this article's cover image, in which case it would be a timely process to find the exact line you want to set a breakpoint on. Instead, a dev can simply do:

function myCodeAintWorkin(arrrrgggh) {
  let thisThing;
  debugger; // <-- runtime will break at this point! (even if this line is buried in the uglified code at line 1112442)
  // Some buggy code here
moca_salter profile image
Monica Salter

debuggger will for sure bless your life πŸ‘Œ

nickytonline profile image
Nick Taylor (he/him) Author

If you're looking for some more great debugging tips, give @umaar a follow. He's not really active on DEV, but he has links to his Twitter and website/newsletter. I mention this in my post on frontend tools.

scrabill profile image
Shannon Crabill

I was using a console.log() for the millionth time this week when I remembered debugger was a thing.

nickytonline profile image
Nick Taylor (he/him) Author

Side note, but there are also logpoints if you don’t want to clutter your actual code.

Nice post. Definitely some great console methods to know!

The more you know

Logpoints are also pretty useful depending on your debugging style.

They've been available in VS Code since June of last year, but they also got introduced in Chrome 73, and added in FireFox 67.