DEV Community

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

Collapse
 
richardeschloss profile image
Richard Schloss • Edited

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
} 
Collapse
 
monicat profile image
Monica Macomber

debuggger will for sure bless your life 👌

Collapse
 
nickytonline profile image
Nick Taylor

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.

Collapse
 
scrabill profile image
Shannon Crabill

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

Collapse
 
nickytonline profile image
Nick Taylor

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.