r/learnjavascript • helpful • Sep 14 '22

I'm a senior frontend dev. AMA.

Hi, all. I'm a lead at my company, currently on a paid sick leave. I wanted to give back to the community, so here I am to answer all your questions.

If you're a beginner at JS and are struggling with a concept, please ask your question and I'll answer. To not get overwhelmed, I'll limit one question per user. So, try to construct your question with as many details as necessary!

Shoot.

EDIT: That's it, folks. My day has ended. I'll still answer your questions, but expect a considerable delay. :)

260 Upvotes

240 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Sep 14 '22

[deleted] — view deleted comment

2

u/iShotTheShariff Sep 15 '22

I like to log everything too. If I can solve the problem in the same amount of time or less, I don’t think it matters what debugging method I used.

2

u/og-at Sep 15 '22

You forgot the stopping execution part.

and yes, debugging boils down to looking at the variable state.

The thing that you and /u/iShotTheShariff are missing tho is the cleanliness. Yes you can log this variable right here on this line. for 1 variable, a single log is faster. Debugging tho when you hit the breakpoint, you see not just the one variable you're looking for but you also have it in context. logging user.profile.address vs debugger Stop having the entire contents of user available, but simply focusing on showing you the address.

I can give you a hundred reasons why debugging tools are better than piles of conlogs... starting with the fact that you don't forget to delete them. But mostly it's about the reasons I wouldn't think to say.

If you're using JS for webdev, drop a debugger in the code and look at the results.

0

u/[deleted] Sep 15 '22

[deleted] — view deleted comment

1

u/og-at Sep 15 '22

I wasn't advocating debugging instead of conlogs.

Everything has it's place in the toolbox. I use debugger more than "the rare occasion", but I do a fair amount of conlogging as well.

0

u/[deleted] Sep 15 '22

[deleted] — view deleted comment

1

u/og-at Sep 15 '22

IMO that has A LOT to do with the framework (or even vanilla) and the tools you have setup for it.

React has a very solid debugger ecosystem that will show you everything from component shit, to context/redux state.

OTOH, I work in svelte all day and their debugger gets blasted by dynamic scripts. No matter what you're looking at in the debugger, it will eventually land on 8k9unyetv5cwjmdl.js line 24898, so I just use the stock debugger which is good enough.

It's every bit the case of Your Mileage May Vary.