1. What is a console used for?
The console allows you to interact with a web page by executing JavaScript expressions within the pageâs context. It can also be used to log information. Changes to the web page do not remain permanent, but disappear when the page is refreshed.
2. How do you open the console in Google Chrome?
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. This will open a panel where you can click on Console along the top menu bar.
3. What does the console.log function do?
console.log allows you to print strings in the console. For example, console.log("Hello World!")
will print the string âHello World!â in the console. console.log(2 + 6)
will print the string â8â in the console.
4. How can you change the contents of an HTML page through the console?
You cannot actually change the html document through the console. Any changes you make will disappear after the page is refreshed. To change an HTML page in its dynamically rendered context, you can open the page in your browser and change its appearance by adding or modifying html elements using JavaScript code. For example:
let d = new Date();
document.body.innerHTML = "<h1>Today's date is " + d + "</h1>"