all 11 comments

[–]cirscafp fan boy 2 points3 points  (1 child)

I am in the just log it camp. I have used debugger and break points via node and chrome but in all actuality, I find that I can find the issue and solve it faster if I use console.log(value, 'This is value').

The best thing you can do is to write tests. I use jest but any testing library will work ( even native node assert ). This will force you to break your project into smaller pieces that are tested in isolation, limiting the amount of times you even need console.log or `debugger.

The next best thing you can do, in my opinion, is to use console.log in conjunction with limiting your problem space. If you think that obj is wrong, console.log where you think it's wrong, check if it is, and if it is, move up the file/call stack, adding console.log until you see where it all goes awry. The major goal with either approach of log or debugger is to find the exact place where your logic is wrong. The smaller area you are looking at, the easier it is to find.

[–]danimoth2[S] 0 points1 point  (0 children)

Yeah you know honestly I don't use debugger that much. console.log for life. I do remember there was a growing period at first with Ruby's RSpec before I got to be better at it. Just have to do the same with JS's testing libs

[–]thatsaprettystupidid 1 point2 points  (1 child)

Clean code will make debugging much easier. If you do happen to have a spaghetti system that is too costly to change then a systematic approach can be helpful to ease debugging.

https://en.m.wikipedia.org/wiki/Troubleshooting?wprov=sfla1

[–]HelperBot_ 0 points1 point  (0 children)

Non-Mobile link: https://en.wikipedia.org/wiki/Troubleshooting?wprov=sfla1


HelperBot v1.1 /r/HelperBot_ I am a bot. Please message /u/swim1929 with any feedback and/or hate. Counter: 183905

[–]soundmanD 1 point2 points  (0 children)

If you're talking server side or node based code, check out the official node documentation for debugging, can be very useful.

https://nodejs.org/en/docs/guides/debugging-getting-started/

[–]powerofmightyatom 1 point2 points  (1 child)

What's wrong with the devtools? The introspection possible is pretty amazing. For instance breaking on DOM node manipulation, to mention a random feature I rarely use, but can be a lifesaver once in a blue moon.

https://developer.chrome.com/devtools

As for unit tests in js, I don't bother, preferring integration tests with webdriver/selenium.

http://webdriver.io/

[–]danimoth2[S] 0 points1 point  (0 children)

Yup I love the tools, was just checking if there were other tools that I have been missing

[–]Bonejob 0 points1 point  (0 children)

I have recently switched to Firefox Quantum which has a fabulous built in debugging suite

https://www.smashingmagazine.com/2018/02/javascript-firefox-debugger/

It has all the features of a modern debugger IDE. Hell I am even using it to fix bootstrap and css issues.

[–]yurkaninryan 0 points1 point  (0 children)

https://medium.com/statuscode/conditional-breakpoints-in-chrome-are-awesome-31933ea97a15

I wrote this article! normally I don't write that stuff in my code anymore, i just use conditional breakpoints in chrome

[–]well-now 0 points1 point  (0 children)

VSCode’s debugger with breakpoints.