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
}
I'm a fan of Open Source and have a growing interest in serverless and edge computing. I'm not a big fan of spiders, but they're doing good work eating bugs. I also stream on Twitch.
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.
I'm a fan of Open Source and have a growing interest in serverless and edge computing. I'm not a big fan of spiders, but they're doing good work eating bugs. I also stream on Twitch.
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:
debuggger
will for sure bless your life 👌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.
Frontend Developer Resources
Nick Taylor (he/him) ・ Jan 6 ・ 11 min read
I was using a
console.log()
for the millionth time this week when I remembereddebugger
was a thing.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!
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.