5 ms·
Practically every time I do a 'console.log' to see the value of something in the current page state I actually wanted a 'debugger' statement instead. Pausing ex
by onion2k 5y ago
Practically every time I do a 'console.log' to see the value of something in the current page state I actually wanted a 'debugger' statement instead. Pausing execution so I can look at other things around what I wanted to log often proves very useful and let's me get to the root cause of a problem faster.
- Griffinsauce 5y agoThis is really missing at the moment. I wish there was a "debugger snapshot" functionality that does not pause execution and creates a snapshot of the current DOM and state. Probably a performance nightmare but being able to continue and inspect what happened in retrospect is what makes console.log a powerful debugging tool IMO. You could extrapolate this to the time-traveling debuggers we've seen for Redux and other tools. That stuff is super powerful.
- MindTwister 5y agoAre you lamenting that you reach for `console.log` first, instead of using the `debugger` statement, or are you wishing there was a `debugger` statement, because there absolutely is a `debugger` statement. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- jansan 5y agoconsole.log(JSON.stringify(myValue, null, 2)) could be what you are looking for.
- onion2k 5y agoThat's just a prettier console log. I almost always want to use the debugger.
- mrblampo 5y agoMaybe my debugger skills aren't strong enough, but I find that when I'm trying to reason about how some complicated code is executing, a debugger statement forces me to wade through tons of internals in libraries I don't care about. Some well-placed console logs give me much less information overload.
- bryanrasmussen 5y agoThe same here, also in my case at least 90% of the time when there is a problem I know where the problem is I just need to look at a couple things and confirm which of a couple scenarios could be causing the problem.
- hibbelig 5y agoInteresting. I feel the opposite. Reading through multiple log lines somehow tells me something about the problem (program) that I don’t get when I use the debugger.