r/javascript • • Apr 08 '18

Javascript Debugging Like a PRO

https://medium.com/appsflyer/10-tips-for-javascript-debugging-like-a-pro-with-console-7140027eb5f6
49 Upvotes

11 comments sorted by

39

u/[deleted] Apr 08 '18

This isn't "Javascript Debugging Like a PRO", this is "fancy console methods" 🧐

6

u/molikreddit Apr 08 '18

It's the same info you would get from the Google Chrome Dev Tools help page.

As previous comments stated - "debugger;" is probably a better statement to use.

8

u/A_BayBay Apr 08 '18

This is the third time I've seen this blog post. Quit spamming bro

1

u/Mittalmailbox Apr 08 '18 edited Apr 08 '18

You don't need most of these if you use real debugger(debugger for Chrome in vscode)

1

u/[deleted] Apr 08 '18

the title should be "console.log like a pro"

1

u/chmarus Apr 08 '18

Pros are not debugging using console.log

0

u/[deleted] Apr 08 '18

[deleted]

5

u/[deleted] Apr 08 '18

Why not just make a breakpoint using the browser so that it isn't part of the code?

8

u/autra1 Apr 08 '18

In some cases that's very useful:

  • I've seen a lot of bugs with js debugger on firefox and chrome with source maps (where putting a breakpoints is not taken into account, or is on the wrong line). Okay these bugs should simply not be there, but when they are, it can help.

  • It's useful when you're debugging node applications: When the application startups, the file you're interested in might not be required yet, thus you can't find it with ctrl+p.

1

u/[deleted] Apr 08 '18

Interesting, thanks!

1

u/PlNG Apr 08 '18

Important to note that debugger still blocks optimizations in turbofan, so be sure to leave it out of production code entirely - the mere presence of the call to debugger stops any function optimizations, even if(false){debugger;}

1

u/ijmacd Apr 08 '18

Won't your minifier get rid of that?