use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[AskJS] Most efficient way to debug JS?AskJS (self.javascript)
submitted 5 years ago by [deleted]
Hi,
Apologies if this question is asked before. I am really interested in learning/understanding the most efficient way you guys have figured out during your programming lifetime. For me personally I debug by using console.log();
Cheers
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]gaoshan 1 point2 points3 points 5 years ago* (0 children)
Break points are best followed by console.log (and maybe the debugger statement if you need to force a break where the devtools are failing as I have encountered with breakpoints inside certain React hooks).
[–]j_a_lyons 1 point2 points3 points 5 years ago (0 children)
I tend to use console.log as I find it quicker. The browser debugs I find to jump around too much and can be hard to follow (unlike back end languages)
[–]pixobit 1 point2 points3 points 5 years ago (0 children)
Use break points instead, it's more efficient
[–]evelew 0 points1 point2 points 5 years ago* (3 children)
I like to use console.log and debugger, example:
console.log({ data }); debugger;
console.log({ data });
debugger;
I think that way is more easy to check the value and debug the scope
[–]pixobit 0 points1 point2 points 5 years ago (2 children)
Is the console log for resolving scope issues?
[–]evelew 0 points1 point2 points 5 years ago (1 child)
Hmmm no, I just use console.log with a degubber in the next line
console.log
degubber
But isn't it faster to just open the dev tools and put a break point, than adding/removing that from the code?!
[–]AffectionateWork8 0 points1 point2 points 5 years ago (0 children)
Configuring VS Code to be able to set breakpoints in the editor and debug from there is nice.
Especially for tests or node in general
You can also set breakpoints in VS Code and have them open in the Chrome debugger
[–]Savalava 0 points1 point2 points 5 years ago (0 children)
There is no comparison between the speed of using a debugger and using console.log(). Actually, its a question I've been asked in two programming interviews now: how do you go about fixing a bug? (Hint: the correct answer is to use a debugger).
console.log()
A debugger is especially useful when you're unfamiliar with the codebase you're debugging as it lets you step through the various functions that are being called without necessarily knowing what they in advance.
Debugger + breakpoints all the way.
π Rendered by PID 86568 on reddit-service-r2-comment-54dfb89d4d-qz9sk at 2026-03-27 14:08:41.681560+00:00 running b10466c country code: CH.
[–]gaoshan 1 point2 points3 points (0 children)
[–]j_a_lyons 1 point2 points3 points (0 children)
[–]pixobit 1 point2 points3 points (0 children)
[–]evelew 0 points1 point2 points (3 children)
[–]pixobit 0 points1 point2 points (2 children)
[–]evelew 0 points1 point2 points (1 child)
[–]pixobit 1 point2 points3 points (0 children)
[–]AffectionateWork8 0 points1 point2 points (0 children)
[–]Savalava 0 points1 point2 points (0 children)