JavaScript console.log()

The JavaScript console.log() method is used to write data/message to the web console. For example:

<!DOCTYPE html>
<html>
<body>

   <script>
      console.log("Hello there!");
   </script>
   
</body>
</html>

To see the output, either press F12 function key, then navigate to Console. Or click on the three vertical dots (Google Chrome) or three vertical lines (Mozilla Firefox), available at right top side of the browser window, like shown in the snapshot given below:

js console log

Then navigate to More tools -> Developer tools, like shown in the snapshot given below:

JavaScript console log

A new interface will be opened in the same window. Now click on the Console to see the output, like shown in the final snapshot given below:

console log example JavaScript

JavaScript console.log() Syntax

The syntax of console.log() method in JavaScript, is:

console.log(message)

The message parameter is required, used to display the log message on the console.

Note - If you notice, the console is available under the Developer tools section. That is why, developer uses console.log() as their tools for testing or debugging purposes.

JavaScript Online Test


« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook




Subscribe Us on YouTube