r/javascript • • Mar 18 '19

What's your favorite, most useful javascript one-liner?

385 Upvotes

422 comments sorted by

View all comments

Show parent comments

2

u/snifty Mar 19 '19

Debugging is embarrassing?

1

u/thisguyfightsyourmom Mar 19 '19

debugger statements went out of style once chrome dev tools became awesome & no one wanted to eff up production by forgetting to remove debuggers before shipping

Dev tools is overpowered & cumbersome for most debugging problems though IMO—drop a debugger in, realize you misspelled a var & move on

2

u/simkessy Mar 19 '19

Dev tools is overpowered & cumbersome for most debugging problems though IMO

...what? Dropping in a debugger statement and pointing in a break point where you would drop your debugger statement is the exact same thing.

1

u/thisguyfightsyourmom Mar 20 '19

I’m a lot faster navigating my files & lines in my editor, and I’ve usually already got them open

1

u/simkessy Mar 20 '19

So you get an error in Chrome, you switch back to your IDE, find the error line (told to you by chrome if it broke on a specific line), type debugger, relaunch / refresh, and hit the debug statement

or you get an error in Chrome, it tells you where it failed, add a break point there, refresh.

One is significantly less steps to me.

1

u/thisguyfightsyourmom Mar 20 '19

I definitely drop breakpoints in if I’m responding to an obvious surface level bug,… it’s when I’m digging into an unknown problem below the surface that I start using debuggers.

WTF is causing this weird async bug

breakpoint in chrome to find the line of the error & see if it’s obvious,… if not

WTF is causing this function to error

sometimes you gotta go to the methods of whatever class, and litter debuggers all over the effin place to see which one is called first

oh shit,… of course it’s the fucking setMoarState method

git blame

fuck, why did I write it this way again?—Probably a good reason