For the convenience of programmers, each browser has a special developer panel. You need to right-click anywhere on the current site page to open this panel. In the menu appeared, you need to select the lowest item (it will be called Inspect or something like that).
Let's understand the possibilities of the console.
With your scripts you can output
data to the console, using the special command
console.log. This is used to debug programs.
As an example, let's output something to the console:
Now let's output the variable value:
let num = 123; console.log(num);
You can output multiple variables in turn:
let num1 = 123; let num2 = 456; console.log(num1); console.log(num2);
You can display multiple variables with single command by writing these variables separated by commas:
let num1 = 123; let num2 = 456; console.log(num1, num2);
Given a variable. Output its value to the console .
Three variables are given. Output their values to the console.
Data type in the console
The console displays strings and numbers in different colors. This often helps to find errors in programs.
Let's print a number and a string side by side so we can see the difference in color:
Print all the data types you know to the console. See how their colors differ.
Errors in the console
alert(eee); // Uncaught ReferenceError: eee is not defined
Make a mistake on purpose in your code. Verify that the error appears in the console. Determine the line of code where the error occurred on.