A word that brings anxiety to most programmers. Why can’t we just build the perfect app? No crashing, no unexpected and unexplainable feedback when interacting with the UI and most importantly, no bugs. I dream of a future where you will simply tell the computer what you want and it will build it without all the human limitations that plaque us. Until that day though, I still need to debug my code.
Console.log has always being my go-to tool to debugging my code. When I wasn’t sure whether a variable had the right data or any data at all, I would just chuck it in a console.log, hit ctrl + s, wait for the app to recompile, run it again and check what is outputted in the console. Ah, the good old simple days.
However, as I started building more complex apps, I soon came to the realisation that every newbie developer comes to: console.log actually sucks. It’s great at the occasional simple check of a variable’s data but when it comes to debugging, it’s like driving to Cape Town from Johannesburg in reverse, sure, you will eventually get there but that is not what the reverse gear is built for. And so, began my quest to learn how to debug.
There are quite a number of tools provided to you to debug your applications. The console.log function is a part of a family of console functions for example. Google Chrome and Firefox offer superb tools tucked away in the F12 button such as the ability to pause execution, watch expressions and API calls. I will discuss a few of this in the next couple of posts. I hope you learn a few things and leave a comment of your favourite debugging tools and methods, I might just check them out.