1. What is the console used for?
The JavaScript Console provides you with a space to try out JavaScript code in real time by letting you use an environment similar to a terminal shell interface. Essentially, the Console provides you with the ability to write, manage, and monitor JavaScript on demand.
2. How do you open the Console in Google Chrome?
To open the JavaScript Console in Google Chrome, you can navigate to the menu at the top-right of your browser window signified by three vertical dots in a row. From there, you can select More Tools then Developer Tools. Or you can also enter into the JavaScript Console by using the keyboard shortcut CTRL
+ SHIFT
+ J
on Linux or Windows.
3. What does console.log function do?
The Console will print a given string or the result of an expression to the Console window and to the file āconsole.logā.
4. How can you change the contents of an HTML page through the console?
The Console provides you with a space to experiment with modifying HTML pages. But bear in mind that as soon as you reload a page following modifying it with the Console, it will return to its state prior to your modifying the document, so make sure to save any changes you would like to keep elsewhere (for example locally). In HTML, JavaScript code is inserted between <script>
and </script>
tags.