JavaScript console.log() with Example

JavascriptWeb DevelopmentObject Oriented Programming

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

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

Example

 Live Demo

<!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

On clicking the “CLICK HERE” button −

raja
Published on 07-May-2020 14:00:25
Advertisements