T
0

Console.log() saved me like 3 hours of debugging yesterday

I kept getting this weird error in my Javascript where a variable was undefined even though I thought I set it. I finally put a console.log() right before that line and saw the issue was actually in a different function 20 lines above. I'm a total beginner so maybe this is obvious stuff but it felt like a superpower. Does anyone else still forget to just check what variables actually hold before going down rabbit holes?
2 comments

Log in to join the discussion

Log In
2 Comments
amy302
amy30212d ago
You said "different function 20 lines above" - was the variable scoped wrong or did you just miss assigning it?
7
the_viola
the_viola12d ago
oh man i have done this so many times. i spent a whole afternoon once chasing a bug that was literally just me spelling "firstName" as "firstname" in one place and not the other. console.log is like a little flashlight in a dark room, you just have to remember to actually turn it on. sometimes i get so focused on the big picture i forget the basics.
5