Using Console.Log()

In early days JS debugging was performed through alert() function - now it is an obsolete practice. The console.log(); is a function that writes a message to log on the debugging console, such as Webkit or Firebug. In a browser you will not see anything on the screen. It logs a message to a debugging console. It is only available in Firefox with Firebug and in Webkit based browsers (Chrome and Safari). It does not work well in all IE releases. The console object is an extension to the DOM. The console.log() should be used in code only during development and debugging. It’s considered bad practice that someone leaves console.log() in the javascript file on the production server. ~~ Source: stackoverflow.com

In your browser, you can use the console.log() method to display data. Activate the browser console with F12, and select "Console" in the menu.

HTML file: Displayed by browser:
<!DOCTYPE html>
<html>
<body>

<h1>My First Web Page</h1>
<p>My First Paragraph</p>

<script>
console.log(5 + 6);
</script>

</body>
</html>

My First Web Page

My First Paragraph

Pressing the F12 key is for Airplane mode on my HP laptop. So I clicked on Tools in the Menu bar, then F12 Developer Tools. To understand better what this is all about, click here.

BackTable of ContentsNext