What is console.log? How to use?

February 21, 2022

What is console.log? How to use?

In this article we will learn what console.log is and also how we can use this function to develop our projects in JavaScript!

What is console.log cover

Hey you programmer, how are you? Let’s learn more about JavaScript!

The Console

First it is necessary to understand that the console is an object, and the log() is just a method of this object

There are several other methods, such as:

  • error();
  • warn();
  • clear();
  • team();
  • table();
  • count();
  • group();
  • and the log() itself;

Each one has its specific use, log() has the function of issuing system debug messages

The Log Method

This console method will send the data directly to the browser console

Which in Chrome can be accessed by: Ctrl + Shift + J

Here on this screen all messages that are inside console.log() will be displayed

So if you have this code:

var test = 'Hello';

You will have the test variable displayed in the console, see it out:

We usually use console.log to track the values of variables during the execution of some code

In order to identify a bug or understand how the code is behaving

Be Careful

Do not expose sensitive variables in the console.log, this may cause security issues in your software

Using this function too much can cause your site to slow down, as the JS runs on the client’s computer

And it depends on the computer resources of the same

The ideal is to delete all console.log when you send the site to production, that is, the server that will be hosted

At least comment the lines


In this article we learned what console.log is and also how we can use it

The log is a method of the console object, which has several other methods that help with messages in the browser console.

And the log() method is used to debug variable values or understand how the system is working

Wanna learn more about JavaScript? Click here!

Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x