JavaScript Basics #2: Meet the Console

JavaScript Basics #2: Meet the Console
Jan Zavrel
Jan Zavrel Follow Last updated: June 18, 2021
Share:

The console is a special part of web browser aimed for developers. It helps us see what’s going on in our code. To make something appear in the console, we can print it with the log command.

To be more specific, the console also refers to a special collection of data and methods called an object. The console is a JavaScript’s keyword. These are special reserved words built into the language.

One of the methods of the console object is the .log(). So, when we write console.log(), the computer will print what we put inside the parentheses.

It’s extremely useful, especially if you want to find out the values stored in the memory.

console.log(5);

This example logs (prints) 5 to the console.

Notice that the code ends with a semicolon. It’s a good habit of ending each statement (line of code) with it.

Time to code!

Now is your turn! Run Google Chrome or Microsoft Edge and hit Control + Shift + J (Windows, Linux) or Command + Option + J (macOS) to run JavaScript Console. Type the code above and hit Enter. You should see 5 printed on the line below the code.

JavaScript Console in Microsoft Edge browser

Follow me on Medium, Twitter, Facebook and YouTube.

Share:
Jan Zavrel
Written by

Jan Zavrel Follow

Developer, Author, Teacher, Evernote Certified Consultant.