Introduction to the console

Go back to JavaScript Index

What is the console?

The console is a panel that is used to show important messages e.g. in connection with testing and debugging.

To gain access to the console, open up your site in the Chrome browser, rightclick and choose Inspect. You should now see a panel that shows the DOM tree of the site.

Click on the arrows to the right of Elements in the top panel and choose Console.

Try typing in the following in the console:

x = 7;
y = 13;
1.0 | Logging in the console

Click Enter to go to the next line.

As you can see, the console logs the numbers that you have given x and y as values.

Now, try adding the next line, without refreshing the page:

x + y;
1.1 | Addition in the console

The result of x + y (20) should now be visible in the console.

Next up

The console is a good tool when testing and debugging - but we need to dig a little deeper into the world of JavaScript for it to make sense, so that is what we'll do now.

Next up: Data Types