3 ms·
Ask HN: Helpful methods for debugging JavaScript / websites?
I find that when I'm coding in Javascript (usually client side), most of my time is spent debugging. It's not something I hear discussed too often, but every time I find some new method for debugging better, my productivity improves a ton. For example, something as simple as right clicking on a function to get its definition has saved me lots of time.
Still, I feel like my way of debugging is pretty ad-hoc and inefficient (perhaps others feel the same?). Was wondering if anyone had any tips / hacks / suggestions for debugging more efficiently.
- astans 10y agoChrome dev tools. Ctrl + Shift + i. Check out the docs, they are great. - Conditional breakpoints! - Avoid "Pause On Caught Exceptions" if you are working with date libraries... unless you blackbox them. - Using the profiler to identify unknown bugs is effective sometimes. This can be initially overwhelming. - Ctrl+p for fuzzy finding loaded resources. - Get comfortable with Continue, Step Over, Step In and Step Out. - $0-4 in the console store the value of the last selected nodes in the inspector. e.g $($0) would provide you with a jQuery wrapped node - "Long Resume" I also recommend you enable capturing async stacktraces and the setting which disables cache when the tools are open.
- mgalka 10y ago> - Conditional breakpoints! Awesome! > - Ctrl+p for fuzzy finding loaded resources. This too
- hbcondo714 10y agoI've used vorlon.js to debug web and Cordova / Ionic mobile apps. "An open source, extensible, platform-agnostic tool for remotely debugging and testing your JavaScript. Powered by node.js and socket.io." http://vorlonjs.com http://vorlonjs.com