#1 Console

Introduction

Chances are, if someone is making a program with JavaScript they are going to use the console for displaying a message and debugging.

But what is the console?

– ( ? )

Open the console

The best way to learn is by first hand experience.

  1. Open your browser of choice (not Internet Explorer)
  2. Go to a blank tab.
  3. Right click and click “Inspect Element” or “Inspect”.
  4. Then there will be a box covering a portion of your screen.
  5. On the top of the box click “Console”.

Display a message

This is the console. It may seem intimidating but it will be surprisingly simple. You may notice when you start typing it autocompletes for you. This is useful when you either forget something or to save time. We are going to output a message to the console. Type what is below:

console.log("Hello World")

You will get the output Hello World. Try putting your own message in there.
In JavaScript console is an object. Objects have properties and methods that you can access with a dot, such as console.log.

More console

JavaScript is mostly composed of objects. We will be looking at other objects, methods, properties and creating an object in later articles.
Previously, I said “properties and methods”, i.e. more than one.

What are some of the other methods of console?
– ( ? )

console.clear() -> Clears all the messages in the console. (You can also use clear())
console.warn(message) -> Creates a warning message
console.error(message) -> Creates an error message
*console.table(data) -> Creates a table with the data provided
We will use this later.

End

Try and experiment with console.log()