Tried and True; Troubleshooting.

Tried and True; Troubleshooting.

The key to becoming a great developer is learning how to troubleshoot effectively.

Every language and platform has built-in methods for troubleshooting. For example — Javascript has console.log() for printing things into the console within dev tools so you can tell whether a function or variable is working correctly.

In PHP — you can use things like var_dump() and print_r() to do something similar.

In this article, I will go further with examples of how you can quickly and effectively troubleshoot in any situation you might find yourself in.

Troubleshooting Javascript

Regardless if you're using a JS framework or good 'ole vanilla Javascript — console.log() is hands down your best friend when it comes to figuring out problems.

Are the variable settings? Is it a string or an integer? Is it an object or an array? Is it NULL?

Just console.log() it, and it'll keep you from aimlessly guessing.

Demonstrating console.log() in Javascript

If you are using a JS framework like Vue or React — you'll undoubtedly find a ton of value in downloading and installing the following Chrome extensions.

Vue Dev Tools

React Dev Tools

Once installed — you'll need to close and reopen your Chrome dev tools to see the new panel. Within this panel are loads of helpful tools that allow you to see what's happening in your Vue and React app.

Troubleshooting PHP

There are tons of fancy environment setups for getting error logs to print out on the screen. However, two extremely powerful functions allow you to diagnose what might be happening with your code quickly.

The for one is var_dump(), which can be a little misleading because it does more than handle variables. It also handles functions too!

    $name = 'Duder McDuderson'

Passing a variable function or object in var_dump() — the next time you refresh your webpage — it will display what's happening.

I'll often use it when setting up loops and conditional with something like var_dump('test') to check if the conditional logic works** the way I want it to.

The other function — print_r() — does the same, but in some environments, it will print the data out in a human-readable way which can be extremely beneficial when working with arrays and objects.


When you find yourself scratching your head — do not hesitate to reach for any of these built-in functions. They will help you save loads of time and get you through some frustrating moments as you're out there building out there in the wild.

Did you find this article valuable?

Support Chris Miller by becoming a sponsor. Any amount is appreciated!