- What is the console used for?
The console is mostly used for testing / minor debugging of JavaScript code as it relates to the DOM or just generally. For example the properties of JavaScript objects and values of variables can be logged to the console to see what they hold and if the correct output is being produced.
- How do you open the Console in Google Chrome?
By navigating to the top right in the browser clicking the 3 vertical dots and then selecting More Tools and then Developer Tools
- What does console.log function do?
It logs whatever it takes as input to the JavaScript console. The input could be a string, number type, JSON object, DOM object, etc.
-
How can you change the contents of an HTML page through the console?
By using innerHTML property of the Document.body object and setting its contents to a string that represents an HTML tag. This HTML tag will be inserted in between the tags of the page at the very end of other HTML that may exist.
This however, is temporary as the page will return to its original state upon reloading.