- What is the console used for?
Most modern web browsers that support standards-based HTML and XHTML will provide you with access to a Developer Console where you can work with JavaScript in an interface similar to a terminal shell. Within the Console, you can type JavaScript code.
You can also work within the context of an HTML file or a dynamically-rendered page in the Console. This provides you with the opportunity to experiment with JavaScript code within the context of existing HTML, CSS, and JavaScript.
- How do you open the Console in Google Chrome?
To open the JavaScript Console in 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.
- What does console.log function do?
Rather than have pop-up alerts that we need to continue to click out of, we can work with JavaScript by logging it to the Console with console.log
.
The console.log function prints the results of the expressions we are evaluating within the console itself.
- How can you change the contents of an HTML page through the console?
You can also work within the context of an HTML file or a dynamically-rendered page in the Console. This provides you with the opportunity to experiment with JavaScript code within the context of existing HTML, CSS, and JavaScript.
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.
The Console provides you with a space to experiment with modifying HTML pages, but it is important to keep in mind that you’re not changing the HTML document when you do things on the Console. In this case, once you reload the page it will return to a blank document.