Let us see how to access the Console in different Web Browsers.
After that, the Developer Console will open which will look somewhat like that.
then click on the Developer tab, which will open the Web Developer menu. With that open, from there click on the Web Console menu tab. after that console tab will pop up from the bottom of the web browser.
you can open the console tab of developer tools very easily on chrome and firefox by default on pressing F12.
Example: adding two digits in the console 2 +2 and press enter and assigning the value 7 to the function myFavouriteNumber
and then calling the defined function to evaluate the Expressions.
you can embedd output inside an HTML element using innerHTML attribute but first you have to access the element by using document.get ElementById(id)method. The innerHTML defines the content of the HTML.
Example: Showing data of summation of two numbers using innerHTML.
You can display Output using document.write() to show the current document content. It is mostly used for testing purpose.
<html> <body> <script> document.write(10 * 6); </script> </body> </html
As such after the HTML document is loaded Using document.write() will not display and erase the existing HTML.
OUTPUT: before clicking the button.
After clicking the button
You can display Output through console.log() method, It is used to write code and generate detail information for debugging purpose.
console.log("Hi Codedec!"); // Print value var x = 10; // variable value is defined var y = 20; var sum = x + y; console.log(sum);// Using console.log() to display the data
You can display Output through the window.alert() method, It displays the content using the alert box and it used to display the message popup content of the current window. User clicks on the ok button of the alert box to close the popup message.