r/javascript • u/kadishay • Apr 08 '18
Javascript Debugging Like a PRO
https://medium.com/appsflyer/10-tips-for-javascript-debugging-like-a-pro-with-console-7140027eb5f66
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
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
1
0
Apr 08 '18
[deleted]
5
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
1
u/PlNG Apr 08 '18
Important to note that
debuggerstill 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, evenif(false){debugger;}1
39
u/[deleted] Apr 08 '18
This isn't "Javascript Debugging Like a PRO", this is "fancy console methods" 🧐