DEV Community

LM
LM

Posted on

The Log Blog

The built-in JavaScript function known as console.log() is an excellent debugging tool. It’s often taught early on in a student's JavaScript learning journey as it allows us to see the results of our code quickly. It takes minutes to learn, but an hour or so to master. Once a JavaScript programmer has a good grasp of console.log(), they will have gained an invaluable tool for debugging their code and learning from the process.

To briefly explain console.log to those who haven’t used it. console.log() is a JavaScipt method. When we give console.log a value, it will log that value to the console. This helps with debugging as it can quickly show us the value of an element we’re working with. The syntax is as follows: console.log(parameter).

To Log, or not to log?

That is the question. And the answer is YES! When we’re coding, it’s all too easy to write lines and lines of code without ever checking to make sure that everything we’re working with does what we think it does. And then once you finally test your code and get a bunch of wacky errors, it’s difficult to tell when the buggy code was put in. However, if you log your values frequently, you’re more likely to catch when buggy code is written.

If you'd like to learn more about console.log, you can find the W3Schools and MDN documentation for it here and here.

Top comments (0)