DEV Community

Cover image for Debugging JavaScript Like a Pro: Tools and Techniques for Finding and Fixing Bugs

Debugging JavaScript Like a Pro: Tools and Techniques for Finding and Fixing Bugs

Ayesha Sahar on February 25, 2023

Introduction JavaScript is a powerful programming language used to create interactive web pages and dynamic user interfaces. However, li...
Collapse
 
ant_f_dev profile image
Anthony Fung

A very comprehensive list!

I'd add that sometimes conditional debugging can make things run slower, but that only starts to matter when running loops with a large number of iterations.

If that becomes a problem, sometimes it's worth just adding the condition into the code temporarily and putting an unconditional breakpoint into the code. For example, if looping through 1000 items for something called foobar, you could do

items.forEach(itm => {
  if (itm.name === 'foobar') {
    const x = 0; // actual logic doesn't matter: this is here just so a breakpoint can be added
  }

  // remaining logic
});
Enter fullscreen mode Exit fullscreen mode
Collapse
 
iayeshasahar profile image
Ayesha Sahar

Thank you so much for sharing about this😊🙌

Collapse
 
lukeecart profile image
Luke Cartwright

Which code editor do you recommend that is best for debugging?

Collapse
 
iayeshasahar profile image
Ayesha Sahar

As far as I know, I don't think there is a code editor just made for "debugging". Just use whatever code editor you normally feel the most comfortable with and use various tools or techniques to debug your code.

Personally speaking, I just use VS Code and it works really well for me.

Collapse
 
pushp1992 profile image
Pushp Singh

I would suggest to use browser developer console for debugging.
It will not only help you in debugging but will also help you to understand how javascript code works in javascript engine step by step.

Tip:
Just use debugger/breakpoint in your code, which will help you to see your code working step by step.

Collapse
 
felipefr profile image
Felipe Rodrigues

Webstorm.

Collapse
 
lukeecart profile image
Luke Cartwright

What do you think of VS code?

Collapse
 
fruntend profile image
fruntend

Сongratulations 🥳! Your article hit the top posts for the week - dev.to/fruntend/top-10-posts-for-f...
Keep it up 👍

Collapse
 
iayeshasahar profile image
Ayesha Sahar

Thanks for featuring my article :)

Collapse
 
stevepenner profile image
Steve P.

I would bet that 50-75% of development time is reduced by fully coding in Typescript and never writing another ".js" file again unless you have legacy code and will do quick fix

Collapse
 
iayeshasahar profile image
Ayesha Sahar

So many devs are adopting Typescript now and it sure is useful👀

Collapse
 
mikec711g profile image
Michael Casile

Thank you for the great summary article. I notice your location is Pakistan and yet your english is impeccable.

Collapse
 
iayeshasahar profile image
Ayesha Sahar

Glad that you liked it!

Well, I guess reading novels and watching tv series + movies with English subtitles does help ;)

Collapse
 
iayeshasahar profile image
Ayesha Sahar

Thanks!

Collapse
 
raowaqarsays profile image
rao waqar

Sounds good , I meet with you on twitter and happy to see you here ...

Collapse
 
iayeshasahar profile image
Ayesha Sahar

🙌

Collapse
 
yaireo profile image
Yair Even Or

Not a single word about source-maps

Collapse
 
iayeshasahar profile image
Ayesha Sahar

Can't possibly fix in everything in just one article :)

There are ofcourse many more amazing methods out there as well! Btw, thanks for this addition.

Collapse
 
airtonix profile image
Zenobius Jiricek

What are the other amazing methods?