After that, a console will open at the bottom of the browser:
The alert() function displays a message box in the browser. As a result, after entering this command and pressing the Enter key, the browser will execute this function and display a window with a message:
To display various kinds of information in the browser console, the special function console.log() is used . For example, let’s define the following web page:
var a = 5 + 8;
Next, using the method console.log(), a message is displayed on the browser console
And at the end, also using the method console.log(), the value of the variable a is displayed on the browser console.
And after launching the web page in the browser, we will see the result of the code execution in the console:
What is very useful, in the browser console you can also notice the line numbers of the code where exactly the output to the console was performed.
In the future, we will often access the console and use the console.log function.
Moreover, we could enter a similar code in the console itself:
We also sequentially enter the instructions and after entering each instruction, press Enter.