4 ms·
You can make a conditional break point, put in arbitray js statements, such as console.log, and return false if you dont want to pause there. Best of both world
by jasonkostempski 8y ago
You can make a conditional break point, put in arbitray js statements, such as console.log, and return false if you dont want to pause there. Best of both worlds and you dont have to clean up the code after.
- lhnz 8y agoI can type `console.log(blah)` into a text file and hit save much faster than I can search for the same file within Chrome right-click and then come up with a working conditional breakpoint dependent on the context around it and type this into a tiny input field. If you understand the code and are currently writing it, it's almost always faster to debug with a `console.log`[0]. This seem to be the case whether you are coding in a browser or running unit tests: reaching for the debugger is slowwww. To me, the debugging experience everywhere seems broken. Why is the only tool we have a breakpoint? What if I don't want to 'block' and just want to mark a point in the code which I want to capture a selection of information about? Why not let me visualise or filter these points, and then click through to see the callstacks and the state that was collected? The whole DX seems to be built around the premise that I want to laboriously step through when I debug. While in 99% of cases as soon as I see some values I instantly know what I have done wrong. The only times I normally use a debugger are when debugging problems on production sites, or when debugging complex problems in other people's code. [0] This might not be the case, if your IDE is extremely well-integrated with your text editor to the extent that you can add breakpoints as easily as you can add log statements. Edit: I just checked and the latest version of VSCode has LogPoints. Perhaps that means others see room for improvement, too.
- bryanrasmussen 8y agoI was thinking more of a specialized console in the browser where you could write code sort of like the following: let b = new BreakPoint(); let start = codebase.find('let creditrating'); let end = codebase.find(functionExit('chanceToPurchaseSet')); let report = new Reporter(); report.preamble = 'line ' + start.lineNumber + ' in file ' + start.codeFile; report.ending = '-------------------'; report.bindTo(b.reports); b.reportOn(['undefined','null',b.error]); start.setBreakpoint(b); start.runUntil(end); with of course requisite functionality to do stuff like save scripts, run a saved script, history of reports etc. on edit: improved formatting