F
9

Hot take: Debugging in the browser console is way better than using print statements

I was at a coding meetup in Austin last month and someone showed me how to set breakpoints in Chrome DevTools live. I used to litter my code with console.log everywhere, but now I can inspect variables and step through line by line. Has anyone else made the switch and found it faster?
3 comments

Log in to join the discussion

Log In
3 Comments
logan271
logan2716d agoMost Upvoted
Honestly I used to be a console.log guy too but once I figured out how to pause on caught exceptions in devtools it was a game changer. Now I just set a conditional breakpoint right where the bug happens and watch the values change as I step through. Saves so much time compared to guessing where to put print statements.
3
kellyallen
Gotta admit, I'm still stuck in the console.log dark ages over here. My breakpoints always seem to hit at the wrong moment (you know, right when I'm not looking at the screen).
3
henry_anderson54
Honestly I was the same way for years, stuck on console.log and hoping I'd stumble onto the right variable. What finally clicked for me was using the "log point" feature in the breakpoints panel, you basically type a message and the variable name right in the line number gutter and it shows up in the console without stopping the code. That way I get a live feed of values as they change without the constant pause and unpause dance.
1