Is console.log The Only Option?
Like me, many of you probably use console.log() to debug your JavaScript code a lot of the time. The problem isn’t big enough to require the setting of breakpoints but you don’t want something intrusive like alert().
Console.log() is great for that. But is it always the best solution?
Some of you may already know about console.log()’s lesser known brother, console.table(). Although, I would take a guess that many of you have never heard of it. I certainly hadn’t heard of it until relatively recently.
I don’t really know why it is such an obscure thing because it is extremely useful.
So this will just be a quick one today. As you may already know, or have already guessed, console.table allows you to print out arrays and objects to the console.
This is great because it’s well organised, unlike the standard dropdowns we get for objects when we console.log them. On top of that you can also sort columns to quickly see exactly what you need to.
Let’s create ourselves an array to practice with:
var turtles = [
{
name: "bob",
type: "loggerhead"
},
{
name: "sally",
type: "leatherback"
},
{
name: "amanda",
type: "green"
}
];
So here we have a happy group of turtles that we can print out in our table.
4 Ways You Can Get Rid of Dirty Side Effects for Cleaner Code in JavaScript. Bugs are born in many ways. Creating side effects is one of them. Some people say side effects are evil, some say they’re not.
Static code analysis is a method of debugging by examining source code before a program is run. It's done by analyzing a set of code against a set (or multiple sets) of coding rules. Static code analysis and static analysis are often used interchangeably, along with source code analysis.
Who Else Wants to Write Clean JavaScript Code? 7 Tips to Make Your Coworkers Fall in Love With Your Code.
Don’t waste time writing long code while you can make it short, yet clearer and easier to read. In this Javascript tutorial, we'll discuss 15 Simple Coding Techniques to Get Your Tasks Done with Shorter Code in JavaScript
How often do you think about the environment that your code runs in, and the resources that are available to it when it runs? Understanding the ‘runtime’ environment can help us make better choices as JavaScript developers when writing code.