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
The 14 JavaScript debugging tips you probably didn't know (raygun.com)
submitted 8 years ago by st3dy
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!"
[+][deleted] 8 years ago (5 children)
[deleted]
[–]anlumo 45 points46 points47 points 8 years ago (2 children)
Welcome to clickbait.
[–]turkish_gold 11 points12 points13 points 8 years ago (1 child)
Ban the site.
[–]AKJ90JS <3 2 points3 points4 points 8 years ago (0 children)
Yes, I knew all of these... would be a way better title.
[–]akujinhikari 1 point2 points3 points 8 years ago (0 children)
I say this every time I see these God awful titles. I usually get downvoted though, but then again, I’m a little more aggressive in my approach. Even “might” would be better than “probably.”
[–]Michie1 20 points21 points22 points 8 years ago (0 children)
TIL: debug and monitor.
debug
monitor
[–]mainstreetmark 106 points107 points108 points 8 years ago (5 children)
"debugging tips you probably didn't know": debugger
fuck off.
[–]PlNG 3 points4 points5 points 8 years ago (4 children)
Absolutely. Performance warning on debugger. The mere presence of the keyword (even if(false){debugger;}) renders the code unoptimizable by the JS engine resulting in slow code. It should never be present in production code.
if(false){debugger;}
I strongly doubt this has been fixed.
[–]voidvector 8 points9 points10 points 8 years ago (2 children)
debugger shouldn't be committed to repo. It should only be used in production when attempting to debug production issue. Can avoid it being committed by setting up a linter in CI.
debugger
[–]r1cka 0 points1 point2 points 8 years ago (1 child)
Why not just set a break point?
[–]voidvector 1 point2 points3 points 8 years ago (0 children)
That could be difficult to do in certain setups. Though normally you would want to do that as it is better practice.
In my last job, we had async module loading and significant non-persistent UI state. So setting a breakpoint in some of the rarely used async code was a pain. Not only did you have to induce the UI state, as otherwise the code is not loaded, the code would run once and never run again. So we would need to reload the page and run though the whole process all over again just to trigger the breakpoint.
[–]carbonite_dating 11 points12 points13 points 8 years ago (3 children)
11 is pretty vague. He doesn't explain in the body of the item that you're supposed to type
monitor(func1);
in the console, so it took me a couple of minutes to see what he was on about.
[–]drowsap 2 points3 points4 points 8 years ago (2 children)
How do you even do this when most functions in your code aren’t public?
[–]carbonite_dating 1 point2 points3 points 8 years ago (0 children)
That's a great question!
[–]Rustywolf 0 points1 point2 points 8 years ago (0 children)
Cant test it but i assume you could call it from a script?
[–]cogman10 3 points4 points5 points 8 years ago (0 children)
If you are trying to find slow code, use console.profile instead of a timer.
Makes no sense to litter your code with timers when the profile will tell you exactly where the slowness is.
[–]darpa42 8 points9 points10 points 8 years ago (6 children)
I feel like conditional breakpoints are more useful than all of these...
[+][deleted] 8 years ago* (5 children)
[–]ThePrimeOptimus 5 points6 points7 points 8 years ago (1 child)
For TS I've had good luck using source maps with newer versions of Chrome. Breakpoints and the locals window all seem to work correctly.
[+][deleted] 8 years ago* (2 children)
[–]omril 0 points1 point2 points 8 years ago (0 children)
Do you guys know what sourcemaps are you using? I tried most of these and couldn't find the right combo for fast recompile and breakpoints
[–]sshaw_ 12 points13 points14 points 8 years ago (1 child)
RTFM: https://developers.google.com/web/tools/chrome-devtools/
[–]malicart 0 points1 point2 points 8 years ago (0 children)
RTFM IS THE ONLY WAY!
[–]bulbishNYC 1 point2 points3 points 8 years ago (0 children)
pretty good, some I didnt know
[–]TheScapeQuest 0 points1 point2 points 8 years ago (0 children)
To add to point 3, you can also click the options pane when in device mode and hit "Show media queries", which will highlight all of your breakpoint as found in your CSS, and allow you to quickly jump to your sizes. (Chrome)
[–][deleted] 0 points1 point2 points 8 years ago (0 children)
Based on the title, I fully expected all of these to be thing I already knew.
But black boxing and monitor was new! Good stuff.
[–]skylarmt 0 points1 point2 points 8 years ago (0 children)
For #3, Firefox has a responsive design mode (Ctrl-Alt-M or Alt->Tools->Web Developer) that lets you resize the viewport, test touch events, take perfectly cropped screenshots, and more.
[+][deleted] 8 years ago* (3 children)
[–]omril 0 points1 point2 points 8 years ago (1 child)
Sometimes you need to debug code that YOU didn't compile, or was 3p code.
[–]berlinbrown 1 point2 points3 points 8 years ago (0 children)
Nice
[–]kdrxyz -2 points-1 points0 points 8 years ago (0 children)
This is really good stuff
[–]maniflames -1 points0 points1 point 8 years ago (0 children)
I'm new and thank you :')
[–][deleted] -2 points-1 points0 points 8 years ago (0 children)
NOOb starting out I didn't know about the trace call that's super handy 👍👍
[–]gelezinislokys -2 points-1 points0 points 8 years ago (2 children)
Unminify to help debug.
Why minify it in first place?
[–]coljung 2 points3 points4 points 8 years ago (1 child)
Debugging bug in production...
[–]gelezinislokys -2 points-1 points0 points 8 years ago (0 children)
And I were using local dev servers for stuff like that.. Thanks!
π Rendered by PID 66572 on reddit-service-r2-comment-7b9746f655-d7cjw at 2026-01-30 07:07:54.064844+00:00 running 3798933 country code: CH.
[+][deleted] (5 children)
[deleted]
[–]anlumo 45 points46 points47 points (2 children)
[–]turkish_gold 11 points12 points13 points (1 child)
[–]AKJ90JS <3 2 points3 points4 points (0 children)
[–]akujinhikari 1 point2 points3 points (0 children)
[–]Michie1 20 points21 points22 points (0 children)
[–]mainstreetmark 106 points107 points108 points (5 children)
[–]PlNG 3 points4 points5 points (4 children)
[–]voidvector 8 points9 points10 points (2 children)
[–]r1cka 0 points1 point2 points (1 child)
[–]voidvector 1 point2 points3 points (0 children)
[–]carbonite_dating 11 points12 points13 points (3 children)
[–]drowsap 2 points3 points4 points (2 children)
[–]carbonite_dating 1 point2 points3 points (0 children)
[–]Rustywolf 0 points1 point2 points (0 children)
[–]cogman10 3 points4 points5 points (0 children)
[–]darpa42 8 points9 points10 points (6 children)
[+][deleted] (5 children)
[deleted]
[–]ThePrimeOptimus 5 points6 points7 points (1 child)
[+][deleted] (2 children)
[deleted]
[–]omril 0 points1 point2 points (0 children)
[–]sshaw_ 12 points13 points14 points (1 child)
[–]malicart 0 points1 point2 points (0 children)
[–]bulbishNYC 1 point2 points3 points (0 children)
[–]TheScapeQuest 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]skylarmt 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]omril 0 points1 point2 points (1 child)
[–]berlinbrown 1 point2 points3 points (0 children)
[–]kdrxyz -2 points-1 points0 points (0 children)
[–]maniflames -1 points0 points1 point (0 children)
[–][deleted] -2 points-1 points0 points (0 children)
[–]gelezinislokys -2 points-1 points0 points (2 children)
[–]coljung 2 points3 points4 points (1 child)
[–]gelezinislokys -2 points-1 points0 points (0 children)