But what is the console?– ( ? )
Open the console
The best way to learn is by first hand experience.
- Open your browser of choice (not Internet Explorer)
- Go to a blank tab.
- Right click and click “Inspect Element” or “Inspect”.
- Then there will be a box covering a portion of your screen.
- 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:
You will get the output
Hello World. Try putting your own message in there.
console is an object. Objects have properties and methods that you can access with a dot, such as
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
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.
Try and experiment with