Using console.log()

We use the console log method mostly to debug our javascipt code in a web browser. Every single web developer use this method to see any errors in their code and it helps you debug those errors. All morden web browsers or almost any other javascipt environments support this console log method.

How to use console.log()

Open any web browser of your choice, go to the javascipt console in your web browser, enter the following code below on your console and then press the enter button on your keyboard to run the code.


Let's log this words "Hello world" to the console.

console.log("Hello world");

The above code will log the following to the console:

Hello word

How to log variables to the console?

When using console.log() you can log any or every variable that you want, you must first write the variable that you want to be displayed to the console using the console log method. Let's make a simple and easy to follow example:

let greet = "Hello everyone";

console.log(greet);

The above code will log the following:

Hello everyone