Computer >> Computer tutorials >  >> Programming >> Javascript

JavaScript console.log() with Example


The JavaScript console.log() method is used to write a message in the console.

Following is the code for JavaScript console.log() method −

Example

<!DOCTYPE html>
<html>
<head>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
</style>
</head>
<body>
<h1>console.log() Example</h1>
<button class="Btn">CLICK HERE</button>
<h3>Click the above button to see output in your console</h3>
<script>
   let test = {
      a:22,
      b:'HELLO',
      c:44,
   }
   console.log(test);
   console.log('HELLO WORLD');
</script>
</body>
</html>

Output

JavaScript console.log() with Example

On clicking the “CLICK HERE” button −

JavaScript console.log() with Example