Console.log debugging vs using a proper debugger, which camp are you in?
I spent my first 3 weeks of learning JavaScript just sprinkling console.log everywhere to figure out what was going wrong. Last Tuesday I finally forced myself to set a breakpoint in VS Code and step through the code line by line, and it took me 5 minutes to find a bug I'd been chasing for 2 days. Now I'm torn, the console.log method feels more intuitive for tiny scripts, but the debugger seems way better for anything with loops or functions. Has anyone else made the switch and found one approach works way better depending on the situation, or is it just me?
Debuggers teach you how the code actually runs, not just what the values are. When you step through a loop you watch the order things happen in, and that is where the real bugs hide. Half the time console.log lies to you because objects print as live references, so by the time you look at that log the object already changed. Spraying logs also makes you guess where to put them, while a breakpoint just stops time and lets you poke around. The catch is you have to learn your editor's debug setup, and for a one-off script that is more work than it saves. Tiny script, log away. Anything with loops or async, step through it.